其他分享
首页 > 其他分享> > Android-单选按钮文字位置

Android-单选按钮文字位置

作者:互联网

我有一个带有RadioGroup和单选按钮的布局.它有效,但显示有问题.我分享了下面的截图.

Android 4.2.1-4.65英寸

平板电脑Android 2.2-7英寸

Android 4.1.2-5.5英寸

bottorbar布局中的代码

<?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>

主布局中的代码

<?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>

我已经工作了几天.我不明白问题.有人能帮我吗 ?

我的偶像

解决方法:

我发现了问题.问题是android:button =“ @ null”.

如果单选按钮具有android:button =“ @ null”属性;
结果:

如果单选按钮没有android:button =“ @ null”属性;
结果:

如果radiobutton具有android:button =“ @ null”和android:background =“” @android:color / transparent“属性
结果:

我为每个单选按钮添加了android:background =“ @android:color / transparent”属性,并解决了问题.

标签:android-layout,radio-group,android
来源: https://codeday.me/bug/20191122/2058429.html