2

内部にlinearlayoutとimageviewがあります。linearlayout は角が丸くなっています。画像をビューの最上部に表示したいのですが、画像が表示されたときに角が丸くなっていません。これには何ができますか?iOS には、コンテナー (UIView) のクリップ サブビュー オプションがあることを知っています。しかし、Androidではわかりません。

 <LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"   
    android:orientation="vertical"
    android:gravity="top"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"  
    android:background="@drawable/cell_rounded_edges">  
    <ImageView
        android:id="@+id/prodImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:gravity="top"   
        android:focusable="false"
        android:clickable="false"   
        android:adjustViewBounds="true"       
        />
.....and so on
4

2 に答える 2

1

Any ViewGroup( を含むLinearLayout) にはブール値の XML 属性android:clipChildren( を使用してプログラムで設定することもできますsetClipChildren(boolean)) がありますが、ドキュメントによると、これはデフォルトで true に設定されています。

于 2012-07-16T21:43:30.793 に答える
0

私は素晴らしく簡単な解決策を見つけました!

レイヤーのすべての角が丸くなっているため、レイアウトの上部に画像があり、上の角だけを丸くする必要がありました (iOS のサブビューへのクリップをシミュレートします)。

私の画像の背景に:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#e3e3e3"/>
<corners android:bottomRightRadius="0dip"
         android:bottomLeftRadius="0dip"
         android:topLeftRadius="25dip"
         android:topRightRadius="25dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

私のレイヤーの背景に:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FFF"/>
<corners android:radius="25dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /> 
</shape>
于 2014-05-21T20:26:40.997 に答える