0

アンドロイドのUIカスタムコントロールを作成することは可能ですか? 1つの線形レイアウトの中に3つのラベルを配置する必要があります。この目的のためにLinear Layoutクラスを拡張する必要がありますか? クラスを拡張しなくても可能ですか(リニアレイアウト) - リニアレイアウトと必要なラベルだけで1つのxmlファイルを使用することを意味しますか? Linear Layoutクラスを拡張しなくても、このXMLファイルだけを使用できますか?事前にxml属性だけを使用してAndroidカスタムコントロールを作成できますか?

おかげ

答えて

0

使用この

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Large Text" 
     /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Large Text" 
     /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Medium Text" 
     /> 

</LinearLayout> 
0

はい、できます。 Zaz Gmyの答えと同じようにXMLレイアウトを作成し、LinearLayoutを拡張してCusomビューを作成する必要があります。次に、ビューを親コンテナとして表示するビューコードでこのレイアウトを展開する必要があります。

inflater.inflate(R.layout.my_layout, this, true); 
関連する問題