相关疑难解决方法(0)

在android中添加自定义单选按钮

我试图获得android中常规按钮的radiobutton效果

我在下面有一个简单的android单选按钮

在此输入图像描述

代码是 ::

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <RadioGroup
        android:id="@+id/radioGroup1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" >

        <RadioButton
            android:id="@+id/radio0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="RadioButton1" />

        <RadioButton
            android:id="@+id/radio1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton2" />

        <RadioButton
            android:id="@+id/radio2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton3" />
    </RadioGroup>


</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

如何自定义如下::

在此输入图像描述

谢谢!

[编辑]使用其中一个答案的代码

在此输入图像描述

但是按钮名称被选择选项如何删除它所掩盖?


{编辑}更多变化

Finall的更改至少应该知道我从三个单选按钮中选择了哪个按钮....是否可以获得如下所示?

在此输入图像描述

xml android

112
推荐指数
7
解决办法
18万
查看次数

在Android上使用SVG图标的最佳做法是什么?

我即将创建我的第一个Android 原生(因此不是基于浏览器的)应用程序,并寻找有关图标创建/配置的一些好的做法.由于它应该支持多个设备/分辨率,我认为最好使用SVG来创建它们.至少有这个lib:http://code.google.com/p/svg-android/承诺在Android上提供对SVG的支持.

到目前为止,我还没有找到描述这个或另一个库的使用的资源作为在设备上呈现SVG图标的方法,所以我有点不愿意使用它.到目前为止,我所看到的最好的是使用SVG作为在不同分辨率下预渲染基于png的图标的源格式.

所以我的问题是:SVG图标是一个很好的选择,可以直接在设备上使用而无需png预渲染步骤(它是否可以工作),如果,为什么似乎没有人使用这种方法?

icons svg android

72
推荐指数
7
解决办法
8万
查看次数

标签 统计

android ×2

icons ×1

svg ×1

xml ×1