0

ActionBar に表示したいレイアウトは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <EditText
        android:id="@+id/etSearch"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1.0"
        android:singleLine="true" />

    <ImageButton
        android:id="@+id/btnSearch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:src="@drawable/ic_magnifying_glass" />

</LinearLayout>

ActionBar を設定するコードは次のとおりです。

@Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content_frame);
        View customNav = LayoutInflater.from(this).inflate(R.layout.custom_action_bar, null);
        getSupportActionBar().setCustomView(customNav);
        getSupportActionBar().setDisplayShowCustomEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
}

TextView が ActionBar を埋めることを期待していました。ただし、次のようになります。

ここに画像の説明を入力

ヒントはありますか?

4

1 に答える 1

0

試しましたか: EditText で: android:weight=80

ImageButton : android:weight=20

とにかく、 RelativeLayout は ActionBarSherlock で動作しませんか? それは良いです

于 2013-02-14T17:00:27.323 に答える