我有一個應用程序,與包含3 ImageView的動作吧,我使用該程序兼容性庫,這裏是代碼:自定義動作條的佈局使用程序兼容性
private void setupActionBar() {
// Inflate a "Done/Cancel" custom action bar view.
final LayoutInflater inflater = (LayoutInflater) this
.getSupportActionBar().getThemedContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
R.layout.my_custom_actionbar, null);
customActionBarView.findViewById(R.id.title);
final ActionBar actionBar = this.getSupportActionBar();
actionBar.setDisplayOptions(
ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM |
ActionBar.DISPLAY_SHOW_HOME |
ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setCustomView(customActionBarView,
new ActionBar.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
);
}
的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal" >
<ImageView
android:id="@+id/facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="@drawable/ic_fb" />
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:src="@drawable/ic_hotels" />
<ImageView
android:id="@+id/tweetter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_tweet"
/>
</FrameLayout>
</RelativeLayout>
自定義操作欄加載沒有問題,但我不能得到正確的佈局
我試圖做的XML文件b的一些變化它沒有工作。所以我忘了什麼?
什麼是'logo' ImageView的?它會替換左側的應用程序圖標嗎?另外,* FrameLayout *的目的是什麼? – Fllo