Ich habe ein Problem beim Festlegen der Theme zu meiner Aktivität. Alles funktioniert perfekt in Pre-Lollipop-Geräten.Seltsames Verhalten von Android-Theme Theme.AppCompat.Light.NoActionBar in Lollipop + Geräte
Ich möchte dieses Layout-Design erreichen:
Bild: 1
ich bereits getan haben, dass dieses xml:
design.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/spec_back"
android:orientation="vertical"
android:weightSum="1">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/spec_back"
android:scrollbars="none">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:background="@color/transparent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_margin="1dp"
android:background="@color/transparent"
android:orientation="horizontal"
android:weightSum="6">
<Button
android:id="@+id/btn_cut"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/blue_spec"
android:clickable="false"
android:gravity="left|center"
android:paddingLeft="3dp"
android:text="@string/CUT"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_cut_ex"
style="@android:style/ButtonBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/EX"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_cut_vg"
style="@android:style/ButtonBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/VG"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_cut_g"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/G"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_cut_f"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/G"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_tex"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/square_trans"
android:text="@string/tex"
android:textColor="@color/blue_spec"
android:textSize="@dimen/font_12" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginBottom="1dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:orientation="horizontal"
android:weightSum="6">
<Button
android:id="@+id/btn_pol"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/blue_spec"
android:clickable="false"
android:gravity="left|center"
android:paddingLeft="3dp"
android:text="@string/POL"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_pol_ex"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/EX"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_pol_vg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/VG"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_pol_g"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/G"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_pol_f"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/G"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_tvg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/square_trans"
android:text="@string/tvg"
android:textColor="@color/blue_spec"
android:textSize="@dimen/font_12" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginBottom="1dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:orientation="horizontal"
android:weightSum="6">
<Button
android:id="@+id/btn_sym"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/blue_spec"
android:clickable="false"
android:gravity="left|center"
android:paddingLeft="3dp"
android:text="@string/SYM"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_sym_ex"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/EX"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_sym_vg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/VG"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_sym_g"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/G"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_sym_f"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/gray_spec"
android:text="@string/F"
android:textColor="@color/white"
android:textSize="@dimen/font_12" />
<Button
android:id="@+id/btn_nobgm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@drawable/square_trans"
android:text="@string/nobgm"
android:textColor="@color/blue_spec"
android:textSize="@dimen/font_12" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="20dp"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Ich habe Ränder von 1dp
zu meinen Tasten, um sie voneinander getrennt zu sehen. Dieses Layout funktioniert perfekt für Pre-Lollipop-Geräte. Aber für Lollipop wird es trotz der Margen zusammengeführt. Ich kann Ränder links und rechts nicht sehen, Rand oben-unten kann gesehen werden. Dieses Problem mehr sein kann, unter dem durch das Bild erklärt ist ein Lollipop Device:
Bild: 2
ich das Thema beantrage:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorPrimary</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:actionModeBackground">@color/colorPrimary</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:textColor">@color/myTextPrimaryColor</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
<item name="android:typeface">serif</item>
</style>
Bitte helfen . Ich blieb hier für die letzten 4 Tage.
@ downvoter sollten Sie den Grund für das Downvoting kommentieren. –
Sie meinen, dass 'Theme' nur oberhalb' 5.0' funktioniert? –
Ja .. Es ist machbar .. aber die Ränder sind nicht da .. wie im ** image2 ** zu sehen ist. –