1

私がやりたいことは、実際には次のような「アクションバー」です。 タパトーク

アクティビティを開始するときに、アクション バーの下にあるビューを置き換えたいと考えています。main.xml の例 (簡略化):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mainLinear"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">


    <!-- SIMPLIFIED ACTION BAR -->
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="fill_parent"
            android:layout_height="65dp"
            android:orientation="horizontal"
            android:background="#333333">

        <Button android:id="@+id/actionBtn"
            android:text="@string/actionText"
            android:textColor="#FFFFFF"
            android:textSize="15sp"
            android:layout_width="0.0dip"
            android:layout_height="wrap_content"
            android:contentDescription="@string/fillImage"
            android:drawableTop="@android:drawable/ic_menu_agenda"
            android:background="@drawable/tab_unselect"
            android:layout_weight="1.0" />

    </LinearLayout>

    <Button
        android:background="@drawable/btn_default_holo_light"
        android:textSize="20sp"
        android:id="@+id/BUTTON1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:textColor="#000000"
        android:text="@string/button"
        android:layout_below="@+id/klassenBtn"/>
</LinearLayout>

私の MainActivity.java では、 setContentView(R.layout.main,xml) を行います

web.xml 内:

    <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/webView1"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"/>

ここで、別のアクティビティ (WebActivity.java) で BUTTON1 (@+id/BUTTON1) を webView1 (@+id/webView1) に置き換えたいと考えています。

前もって感謝します!

4

1 に答える 1

1

WebView とボタンを同じレイアウトに配置できます。可視性を設定すると、ウィジェット間にスペースが割り当てられません。

その後、ウィジェットの可視性を変更できるのはあなただけです。

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="65dp"
    android:background="#333333"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/actionBtn"
        android:layout_width="0.0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1.0"
        android:background="@drawable/tab_unselect"
        android:contentDescription="@string/fillImage"
        android:drawableTop="@android:drawable/ic_menu_agenda"
        android:text="@string/actionText"
        android:textColor="#FFFFFF"
        android:textSize="15sp" />
</LinearLayout>

<Button
    android:id="@+id/BUTTON1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/klassenBtn"
    android:background="@drawable/btn_default_holo_light"
    android:gravity="center_vertical|center_horizontal"
    android:text="@string/button"
    android:textColor="#000000"
    android:textSize="20sp"
    android:visibility="visible" />

<WebView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:visibility="gone" 
    android:background="#ad00fc"/>

于 2012-12-01T12:19:47.527 に答える