背景が透明でいくつかのビューが中央に配置された相対レイアウトがあります。このレイアウトを拡張し、addView()を使用してメインレイアウトに追加します。拡張されたビューは、コーナーの中央の要素を親レイアウトに追加するだけです。追加されたビューをすべての画面に表示させることはできますか(fill_parentを試しましたが、無視されます)これは私が膨らませたビューです
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent" >
<RelativeLayout
android:id="@+id/layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@color/info_bar_bg_color" >
<ImageView
android:id="@+id/channel_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/channel_pic"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/title_color"
android:textSize="@dimen/title_text_size" />
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/date_color"
android:textSize="@dimen/date_text_size" />
<TextView
android:id="@+id/hourStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/date"
android:textColor="@color/title_color"
android:textSize="@dimen/title_text_size" />
<TextView
android:id="@+id/hourEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/hourStart"
android:textColor="@color/title_color"
android:textSize="@dimen/title_text_size" />
<ImageView
android:id="@+id/share_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/epgshare_0" />
<ImageView
android:id="@+id/bell_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/share_pic"
android:src="@drawable/epgsharebell_0" />
</RelativeLayout>
</RelativeLayout>
これがビューを追加するメインレイアウトです
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_launcher"
tools:context=".MainActivity" >
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="openInfoBar"
android:text="Open InfoBar" />
</RelativeLayout>