2012-03-17 30 views
2

我设计了一个活动,其中有两个单选按钮 但这些大小足够我想减少它 我正在使用文本这降低了纯文本 如果布局尺寸减小是减少大小只能浏览不能单选按钮圈如何在不使用新图像的情况下减少Android中单选按钮上显示的图像的大小

<RadioGroup 
     android:id="@+id/RG1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/N" 
      android:layout_width="wrap_content" 
      android:layout_height="30dip" 
      android:text="Yes" 
      android:textSize="12dip" /> 

     <RadioButton 
      android:id="@+id/Y" 
      android:layout_width="wrap_content" 
      android:layout_height="30dip" 
      android:checked="true" 
      android:text="No" 
      android:textSize="12dip" /> 
    </RadioGroup> 
+0

你可以给'机器人:layout_height = “WRAP_CONTENT”'每个'RadioButton'。但是你的问题标题和问题有些不同。在你的标题中,你会询问如何减少显示的**图像的大小,但在你的问题和代码中,你似乎没有使用任何图像。请重新设定您的问题。 – Ghost 2012-03-17 06:23:18

+0

是的,我想减少默认图像的大小不是新图像 – Trikaldarshi 2012-03-17 06:25:23

+0

_我question_:图像,配偶在哪里? – Ghost 2012-03-17 06:26:21

回答

2

为此,您可以使用一个选择

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/1" 
    android:state_pressed="true"/> 
<item android:drawable="@drawable/2" 
    android:state_checked="true"/> 
<item android:drawable="@drawable/3" 
    android:state_focused="true" /> 
<item android:drawable="@drawable/4" /> 
</selector> 

,并在单选按钮标签,你CA n add

android:button="@drawable/above" 
android:layout_height="20dp" 
android:layout_width="wrap_content" 

希望它能帮到你。你可能也想看看这个link

0

对于我这个代码的工作!

button.getCompoundDrawables(); 
compoundDrawables[1].setBounds(10, 10, 90, 90); 
0

正确的方法是使用您的自定义drawables单选按钮的状态。要减小自定义绘图的图像大小,请检查THIS

+0

@Alish Answere的正确副本 – Trikaldarshi 2016-02-25 09:18:09

+0

没有先生,它的不同。当您使用自定义drawable时,它很难让单选按钮上的大小减小。是的,它不能满足你不使用新图像的需要,但是,对于任何遇到困难的人来说,减少自定义drawable的大小,就像我一样,它的工作非常好。 – Sarasranglt 2016-02-25 09:44:09

+0

顺便提一下,@ Alish的回答告诉你**减小单选按钮的大小**但是我所说的是**减小单选按钮上图像的大小** – Sarasranglt 2016-02-25 09:47:01

0

访问此页面http://android-holo-colors.com/,选择电台和下载输出资源(zip文件包含一个“资源”文件夹中),包含所有更多钞票单选按钮状态的所有图像,与您的自定义更换图片,但保持了下载文件的大小文件。如果你认为它有太多的状态,只需从xml drawable主题中的选择器中删除即可。

enter image description here

相关问题