2011-07-22 7 views
1

私は目覚まし時計アプリケーションを開発中です。私は、既存のすべてのアラームを一覧表示するアクティビティが必要です。 ListViewの各行にカスタムレイアウトを使用しています。アラームの説明、タイプ、時刻が表示されます。ここで丸みを帯びたアンドロイドのリストアイテムの子ビュー

は、行のレイアウトです:また

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="@drawable/selector"> 
    <TextView 
     android:id="@+id/time" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/time_background" 
     android:textColor="#ffffff" 
     android:layout_marginTop="6dp" 
     android:layout_marginLeft="6dp" 
     android:layout_marginRight="6dp" 
     android:padding="6dp" 
     android:textSize="36sp" 
    /> 
    <TextView 
     android:id="@+id/description" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@id/time" 
     android:paddingTop="6dp" 
     android:textStyle="bold" 
     android:textSize="20sp" 
     android:textColor="#000" 
    /> 
    <TextView 
     android:id="@+id/type" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/time" 
     android:layout_below="@id/description" 
     android:textSize="18sp" 
     android:textColor="#000" 
    /> 
</RelativeLayout> 

活動のためのレイアウトalarm_item_2.xml:私が欲しいものview_alarms.xml

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      > 
<ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:cacheColorHint="#fff" 
    android:background="#fff" 
    android:drawSelectorOnTop="true" 
/> 
</LinearLayout> 

は、時刻を表示するビューを黒にすることです丸みのあるコーナーがあります。私は、形状のリソースを使用しています:RESでtime_background_xml /描画可能フォルダ:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
    <solid android:color="#000000"/> 
    <corners android:radius="10dp"/> 
</shape> 

ただし、ボタンの背景が白のまま。私のコードの問題は何ですか?明らかに、私は何か重要なことを逃しています。

答えて

0

私はtime_background_xmlはこのようにすべきだと思います。

<?xml version="1.0" encoding="UTF-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="rectangle"> 
      <solid android:color="#000000"/>  
      <corners android:radius="10dp"/> 
     </shape> 
    </item>  
</layer-list> 

は、より多くの助けのためのthisを見てみましょう。

UPDATE:

私はこれがうまくいくと思う:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> 
    <solid android:color="#000000"/>  

    <stroke android:width="3dp" 
      android:color="#000000"/> 

    <padding android:left="1dp" 
      android:top="1dp" 
      android:right="1dp" 
      android:bottom="1dp"/> 

    <corners android:radius="10dp"/> 
</shape> 

また、代替ソリューションのthisを見てみましょう。

+0

動作しません。背景はまだ透明です。 は複数のアイテムを描画するのに適していますが、私のレイアウトでは角が丸い黒い矩形が必要なので、通常は単純なで十分です。 – Gabriel

関連する問題