2013-04-06 2 views
0

이 그림의 하단에 표시된대로 이미지가있는 버튼을 만들고 싶습니다. https://trianglewiki.org/RGreenway_App/_files/android.jpg/_info/. 레이어 목록 및 모양 드로어 블을 사용하여 매우 비슷한 단추를 만들 수 있습니다. 내 문제는 내 이미지가 원하는대로 단추 내부에서 확대되지 않는다는 것입니다. 링 모양이 이미지의 상단에 오지만 내부에는 이미지가 없습니다.Android : 반지 모양의 둥근 이미지

이미지가 완전히 링 안에 있어야합니다. 내가 제공하고있는 매개 변수 값에 문제가 있다고 생각합니다. 하지만 내가 올바른 방법으로하지 않을 수 있습니다.

누군가 내 xml 파일을 확인하고 문제가 무엇인지 확인하거나 위의 링크 에서처럼 버튼에서 동일한 효과를 얻도록 정보를 제공 할 수 있습니까? (고해상도에서/당김) 감사

custom_button.xml

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

custom_layout (입술에 /있는 LinearLayout의 배경 당김)

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

header.xml (고해상도에서/레이아웃)

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

답변

1

귀하의 질문에 대한 이해가 너무 복잡합니다. 대답은 here입니다. 그것은 내가 과거에 사용한 트릭입니다.

+0

답변 해 주셔서 감사합니다. 그 쪽이 맞는 거 같아요! 나는 단지 더 간단한 것을 생각해야한다! – user2188951