Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Radio Group Button Text Position

I have a layout which have RadioGroup and radiobuttons. it works but there are problems in display. I've shared the screenshots below.

Android 4.2.1 - 4.65 inch
Android 4.2.1  - 4.65 inch

Tablet Android 2.2 - 7 inch
Tablet Android 2.2 -  7 inch

Android 4.1.2 - 5.5 inch
Android 4.1.2  - 5.5 inch

code from the 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 from main layout

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

I have been working for a few days.I didn't understand problem. Can someone help me ?

my icon my icon

like image 604
Caner Balım Avatar asked Aug 11 '26 02:08

Caner Balım


1 Answers

I found problem. The Problem is android:button="@null".

If the RadioButton has the android:button="@null" property the result will be: enter image description here

If the RadioButton doesn't have the android:button="@null" property the result will be: enter image description here

If the RadioButton has the android:button="@null" and android:background="@android:color/transparent" properties the result will be: enter image description here

I added the android:background="@android:color/transparent" property to all RadioButtons and the problem was resolved.

like image 130
Caner Balım Avatar answered Aug 13 '26 16:08

Caner Balım



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!