Android:环形内的圆形图像
我想创建一个按钮,里面有图片,如图底部所示。我正在尝试使用图层列表和形状绘图,并能够创建非常类似的按钮。我的问题是,我的图像没有按我希望的那样在按钮内缩放。圆环形状出现在图像顶部,但图像不在其内部 我希望图像完全在戒指里面。我认为我给出的参数值有问题。但也有可能是我做得不对 有人能检查一下我的xml文件,看看有什么问题,或者给我提供一些信息,让我在按钮上得到与上面链接中相同的效果。谢谢 custom_button.xml(分辨率/可绘制)Android:环形内的圆形图像,android,android-linearlayout,shapedrawable,layer-list,Android,Android Linearlayout,Shapedrawable,Layer List,我想创建一个按钮,里面有图片,如图底部所示。我正在尝试使用图层列表和形状绘图,并能够创建非常类似的按钮。我的问题是,我的图像没有按我希望的那样在按钮内缩放。圆环形状出现在图像顶部,但图像不在其内部 我希望图像完全在戒指里面。我认为我给出的参数值有问题。但也有可能是我做得不对 有人能检查一下我的xml文件,看看有什么问题,或者给我提供一些信息,让我在按钮上得到与上面链接中相同的效果。谢谢 custom_button.xml(分辨率/可绘制) 自定义_布局(线性布局背景的分辨率/可绘制) h
自定义_布局(线性布局背景的分辨率/可绘制)
header.xml(在res/layout中)
如果我理解你的问题,你就太复杂了。寻找答案。这是我过去用过的伎俩。谢谢你的回答!我认为你是对的!我应该想想更简单的办法!
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/map"/>
<item>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="20dp"
android:innerRadiusRatio="1.75"
android:shape="ring"
android:thicknessRatio="25"
android:useLevel="false"
>
<gradient
android:angle="90"
android:endColor="#FFFFFF"
android:startColor="#FFFFFF" />
<size
android:width="50dp"
android:height="40dp" />
<solid android:color="#008000" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#FF000000"
android:endColor="#FFFFFFFF"
android:type= "linear" />
<stroke
android:width="1dp"
android:color="#FF000000" />
<padding
android:left="5dp"
android:right="5dp"
/>
<size
android:height="50dp"
/>
<solid
android:color="#00FF00"
/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/buttonBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/custom_layout"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:contentDescription="Button"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:background="@drawable/custom_button"
android:scaleType="fitXY"
android:color="#ff0000"
/>
<ImageButton
android:id="@+id/map"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@drawable/custom_button"
android:contentDescription="Map"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:scaleType="fitXY"
/>
<ImageButton
android:id="@+id/weather"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@drawable/custom_button"
android:contentDescription="Weather"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:scaleType="fitXY"
/>
<ImageButton
android:id="@+id/citilink"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@drawable/custom_button"
android:contentDescription="CitiLink"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:scaleType="fitXY"
/>
</LinearLayout>