3

Nur ich mein Studio (Version 2.3) und bauen Version zu aktualisieren ('25 .0.0'),automatisch hinzugefügt ConstraintLayout Abhängigkeit in gradle

jetzt, wenn ich versuche, dann neue Aktivität erstellen automatisch constraintlayoutdependency hinzugefügt in meiner build.gradle Datei.

und Layout rendern als übergeordnet ConstraintLayout, kann jemand wissen, wie diese Abhängigkeit zu entfernen, wenn Aktivität erstellt wird.

Vor der Erstellung der Aktivität Gradle-Code.

dependencies { 
    compile 'com.android.support:support-v4:23.2.1' 
} 

Nach Aktivität Erstellung gradle Code.

dependencies { 
    compile 'com.android.support:support-v4:23.2.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.0' 
} 
+0

leer Aktivität erstellen (Neu-> Aktivitäts-> leer Aktivität), wenn Sie nicht wollen, 'ConstraintLayout'. – Spartan

Antwort

4

Sie können Standard-Template-Layout-Datei in Android Studio Ressourcen ändern, Weg zu ihm:

C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout 

Datei bearbeiten simple.xml.ftl und ändern Layout Ihrer Wahl feststellen, dass einige Layouts zusätzliche Elemente erfordern (zB LinearLayout benötigt android:orientation), Datei speichern und Aktivität in Android Studio erstellen, sollte es funktionieren.

-Mine sieht wie folgt aus (ich habe 2.2.3, so habe ich RelativeLayout)

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
<#if hasAppBar && appBarLayoutName??> 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
</#if> 
    android:id="@+id/${simpleLayoutName}" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
<#if hasAppBar && appBarLayoutName??> 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/${appBarLayoutName}" 
</#if> 
    tools:context="${relativePackage}.${activityClass}"> 

<#if isNewProject!false> 
    <TextView 
<#if includeCppSupport!false> 
     android:id="@+id/sample_text" 
</#if> 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" /> 
</#if> 
</RelativeLayout> 
+0

Ich benutze Linux Ubuntu –

+0

Prinzip wird Simlar, gehen Sie zu Android Studio-Ordner auf den Pfad, den ich schrieb oder suchen Sie nach Datei 'simple.xml.ftl' – miljon

+0

das funktioniert, aber Sie gegeben halbe Antwort, was ich dann automatisch grdle Abhängigkeit wird nicht hinzugefügt –

Verwandte Themen