【问题标题】:How to decrease the size of an Image on a RadioButton to a desired size in Android?如何将 RadioButton 上的图像大小减小到 Android 中所需的大小?
【发布时间】:2016-07-04 21:09:15
【问题描述】:

我正在尝试形成 3 个带有图像的单选按钮。所以我使用了 XML 属性android:button。但由于我的图片尺寸太大,我看不到它适合按钮。

以下是我的 XML 代码:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/netbankingRoot"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="10dp"
    android:layout_marginTop="50dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    tools:context=".activities.fragments.NetBankingFragment">


    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/listOfBanks"
        android:padding="20dp"
        android:layout_marginLeft="60dp">

        <TableRow
            android:layout_marginBottom="5dp">
            <RadioButton
                android:layout_height="60dp"
                android:layout_width="60dp"
                android:id="@+id/sbi"
                android:text="SBI"
                android:padding="30dp"
                android:button="@drawable/sbilogo"
                android:layout_marginRight="20dp"/>


            <RadioButton
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:id="@+id/axis"
                android:text="AXIS"
                android:padding="10dp"/>

        </TableRow>

        <TableRow
            android:layout_marginBottom="5dp">

            <RadioButton
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:id="@+id/citi"
                android:text="CITI"
                android:padding="10dp"/>

        </TableRow>




    </TableLayout>
</ScrollView>

我在这里得到的是。我想要到达这里的是

感谢您的宝贵时间!

【问题讨论】:

    标签: java android image android-fragments android-radiobutton


    【解决方案1】:

    我认为您必须通过使用其他一些图像编辑工具作为“Paint.net”来缩小图像

    【讨论】:

    • 只有这样吗??
    • 我也必须使用这种方式...经过长时间的搜索我也发现只有这种方式..
    • 试过了..没用。你知道ImageButton在Android中是否可以用作RadioButton吗?
    • 我们可以将drawables与单选按钮一起使用...
    【解决方案2】:

    你应该将你的drawables放在一个单选按钮的xml文件中,然后简单地将android:button设置为xml文件,而不是drawable。如果这样做,您可以使用宽度/高度属性简单地更改大小。有关更多信息,请阅读此线程 How can I set the width of radio buttons to change with regards to screen size? (android) 及其最佳答案。

    【讨论】:

      猜你喜欢
      • 2019-02-14
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-01
      • 2012-06-19
      • 2012-08-09
      相关资源
      最近更新 更多