Android – Textposition der Optionsfeldgruppe
-
21-12-2019 - |
Frage
Ich habe ein Layout mit RadioGroup und Radiobuttons.Es funktioniert, aber es gibt Probleme bei der Anzeige.Ich habe die Screenshots unten geteilt.
Android 4.2.1 – 4,65 Zoll
Tablet Android 2.2 - 7 Zoll
Android 4.1.2 – 5,5 Zoll
Code aus dem Bottorbar-Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:padding="3dp" android:gravity="center"
android:background="@drawable/bottom"
>
<RadioGroup
android:id="@+id/radioTur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:measureWithLargestChild="true"
android:layout_gravity="center_vertical"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rad_anasayfa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:button="@null"
android:gravity="center"
android:drawableTop="@drawable/anasayfabutton"
android:textColor="@color/White"
android:onClick="Anasayfa_TIKLA"
android:text="Anasayfa" >
</RadioButton>
<RadioButton
android:id="@+id/rad_haber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/haberlerbutton"
android:textColor="@color/White"
android:onClick="Haber_TIKLA"
android:text="Haberler" >
</RadioButton>
<RadioButton
android:id="@+id/rad_duyuru"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/duyurubutton"
android:textColor="@color/White"
android:onClick="Duyuru_TIKLA"
android:text="Duyurular" >
</RadioButton>
<RadioButton
android:id="@+id/rad_yemek"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/yemekbutton"
android:textColor="@color/White"
android:onClick="Yemek_TIKLA"
android:text="Yemek" >
</RadioButton>
<RadioButton
android:id="@+id/rad_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@null"
android:gravity="center"
android:layout_weight="1"
android:onClick="Arama_TIKLA"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableTop="@drawable/search_icon"
android:textColor="@color/White"
android:text="Arama" >
</RadioButton>
</RadioGroup>
</LinearLayout>
Code aus dem Hauptlayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/AnaLayout"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<include
android:id="@+id/cell1"
android:layout_height="wrap_content"
layout="@layout/bottombar"
/>
</LinearLayout>
</RelativeLayout>
Ich arbeite seit ein paar Tagen. Ich habe das Problem nicht verstanden.Kann mir jemand helfen ?
meine Ikone
Lösung
Ich habe ein Problem gefunden.Das Problem ist Android: Button="@ null".
wenn radiobutton Android hat: Button="@ null" Eigentum;
Wenn RadioButton nicht Android hat: Button="@ null" Eigenschaft;
Wenn RadioButton Android hat: Button="@ null" und Android: Hintergrund="@android: farbe / transparente" Eigenschaft
Ich fügte Android hinzu: Background="@Adroid: Farbe / transparent" Propory, in denen jedes RadioButton und das Problem gelöst wurde.
Andere Tipps
Unter dem Layout ausprobieren. Ich habe allen Radiobuttons ein gleiches Gewicht zugewiesen, so dass es seine Größe entsprechend der Bildschirmgröße anpassen wird. Es funktioniert jetzt gut.Ändern Sie Ihre Bilder, die Ihnen angerechnet werden.
generasacodicetagpre.Versuche dies..
Ändere das RadioGroup
Breite als match_parent
und versuche.
<RadioGroup
android:id="@+id/radioTur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:measureWithLargestChild="true"
android:layout_gravity="center_vertical"
android:orientation="horizontal" >
Und
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<include
android:id="@+id/cell1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/bottombar"
/>
</LinearLayout>
Hier ist mein vollständiger Code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="3dp" >
<RadioGroup
android:id="@+id/radioTur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:measureWithLargestChild="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rad_anasayfa"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Anasayfa_TIKLA"
android:text="Anasayfa"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_haber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Haber_TIKLA"
android:text="Haberler"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_duyuru"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Duyuru_TIKLA"
android:text="Duyurular"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_yemek"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Yemek_TIKLA"
android:text="Yemek"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
<RadioButton
android:id="@+id/rad_search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@drawable/uP13v"
android:gravity="center"
android:onClick="Arama_TIKLA"
android:text="Arama"
android:textAppearance="?android:attr/textAppearanceSmall" >
</RadioButton>
</RadioGroup>
</LinearLayout>