現在、次のレイアウトがあります。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editorRootView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout android:id="RL1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1">
<!-- LinearLayout needed so we have an border outside of the EditorView -->
<LinearLayout android:id="LL1"
android:background="@drawable/border"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<xenolupus.EditorView
android:id="@+id/editorView"
android:layout_width="300dip"
android:layout_height="216dip" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:orientation="horizontal" >
<Button
android:id="@+id/otherImage"
android:layout_width="150dip"
android:layout_height="60dip"
android:text="@string/cardEditor_OtherImageButtonText" />
<Button
android:id="@+id/next"
android:layout_width="150dip"
android:layout_height="60dip"
android:text="@string/cardEditor_NextButtonText" />
</LinearLayout>
</LinearLayout>
そして使用された @drawable/border:
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#FFFFFF" />
<stroke
android:width="10dip"
android:color="#FF0099CA" />
<padding
android:left="10dip"
android:top="10dip"
android:right="10dip"
android:bottom="10dip" />
<corners
android:radius="5dip" />
</shape>
ただし、Eclipse は、RelativeLayout RL1 の LinearLayout LL1 は役に立たないため、削除する必要があることを警告します (! が付いた黄色の三角形)。
この LinearLayout レイアウトまたはその RelativeLayout 親は役に立ちません。背景属性を他のビューに転送します。
EditorView を中央に配置するには RelativeLayout が必要なので、LinearLayout LL1 を削除して、LinearLayout LL1 の Android:background を EditorView に追加してみました。ただし、これを行うと、EditorView のコンテンツの背後に境界線が表示されなくなります。
EditorView の外に境界線を追加する別の方法はありますか、それとも警告を無視する必要がありますか?
ご挨拶ゼノ・ルプス