0

何時間も経っても、アクティビティの下部にあるボタンを修正できません。目に見えないか、上部にあります。相対レイアウトなしでも試しましたが、別の線形レイアウトを追加しようとしましたが、このボタンの設定方法はまだわかりません。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".News" >

    <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="wrap_content"
        android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/news" />

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


    <Button
        android:id="@+id/newsbutton"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="Chiudi" />

</LinearLayout>
</RelativeLayout>
4

4 に答える 4

1
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

    <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/news" />

    <WebView
            android:id="@+id/webView1"
            android:layout_below="@id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />


    <Button
            android:id="@+id/newsbutton"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_alignParentBottom="true"
            android:text="Chiudi" />
</RelativeLayout>
于 2013-01-07T22:10:17.323 に答える
0

まず、レガシー Android レイアウト エディターで、RelativeLayout または LinearLayout は役に立たないという警告が表示されます。それがヒントになるはずです。警告に注意してください。ほとんどの場合に役立ちます。

実際、LinearLayout を取り除くことができます。

したがって、解決策は次のとおりです。

  1. LinearLayout を削除します。
  2. Web ビューに追加android:layout_below="@+id/imageView1"します。
  3. android:layout_alignParentBottom="true"ボタンに追加します。
  4. android:contentDescriptionImageViewに追加します。
  5. ハードコードされた文字列の代わりに @string を使用します。

オプションの手順は太字ではなく、警告を削除します。

Android 4.1.2 でテストされた作業コード全体:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:contentDescription="TODO: DESCRIPTION"
        android:src="@drawable/ic_launcher" />

<WebView
    android:id="@+id/webView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageView1" />


<Button
        android:id="@+id/newsbutton"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_alignParentBottom="true"
        android:text="Chiudi" />

</RelativeLayout>
于 2013-01-07T22:19:24.283 に答える
0

ボタンコンポーネントに次をコピーして貼り付けます;)

    android:layout_marginBottom="147dp"
    android:layout_marginTop="50dp"
    android:layout_marginleft="50dp"
    android:layout_marginRight="47dp"

数字だけで遊んでみてください。きっとコツがつかめます :)

于 2013-01-08T00:26:23.930 に答える
-1

ボタンに android:layout_below="@id/webView1" を追加するだけです。

LinearLayout を使用する場合は、次のように空のスペースを埋める Widget を設定できます: layout_height="0dp" and layout_weight="1". これも仕事をするはずです。

于 2013-01-07T22:09:58.210 に答える