3

まず第一に、私はAndroid開発に不慣れなので、これは単純な問題かもしれませんが、実際には機能させることができません。

私は次のレイアウトを持っています。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              android:orientation="vertical" 
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent"
              android:weightSum="1">

    <FrameLayout android:id="@+id/navigationBarFrameLayout" 
                 android:layout_width="fill_parent"
                 android:layout_height="44dp">
        <ImageView android:id="@+id/navigationBar"
                   android:src="@drawable/navigationbar"
                   android:layout_width="fill_parent" 
                   android:layout_height="fill_parent"
                   android:scaleType="centerCrop"/>
        <TextView android:text="TextView"
                  android:layout_width="fill_parent" 
                  android:id="@+id/navigationBarTitle" 
                  android:layout_height="fill_parent" 
                  android:gravity="center_vertical|center_horizontal"
                  android:textColor="#000" 
                  android:textSize="24sp" 
                  android:textStyle="bold"
                  android:shadowColor="#fff"
                  android:shadowDy="-1" 
                  android:shadowDx="0"
                  android:shadowRadius="1"/>
    </FrameLayout>

    <android.support.v4.view.ViewPager 
             android:layout_width="fill_parent"
             android:id="@+id/DayPager"
             android:layout_height="82dp">
    </android.support.v4.view.ViewPager>

    <RelativeLayout android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:id="@+id/relativeLayout">
        <HorizontalScrollView android:id="@+id/ScheduleScrollView" 
                                  android:layout_width="wrap_content" 
                                  android:layout_height="fill_parent"
                                  android:fadingEdge="none" 
                                  android:layout_above="@+id/tabBarFrameLayout"
                                  android:scrollbars="none" 
                                  android:background="#00ff00">
            <RelativeLayout android:id="@+id/ScheduleRelativeLayout" 
                                    android:layout_height="fill_parent"
                                    android:layout_width="wrap_content">
                <RelativeLayout android:layout_width="fill_parent" 
                                            android:layout_height="wrap_content" 
                                      android:id="@+id/ScheduleTimelineRelativeLayout">
                            </RelativeLayout>
                <RelativeLayout android:layout_width="fill_parent"
                                            android:layout_height="fill_parent" 
                                      android:id="@+id/ScheduleConcertsRelativeLayout"
                            android:layout_below="@+id/ScheduleTimelineRelativeLayout"
                                            android:background="#ff0000" 
                                            android:layout_weight="1">
                           </RelativeLayout>
            </RelativeLayout>
        </HorizontalScrollView>

        <FrameLayout android:id="@+id/tabBarFrameLayout" 
                     android:layout_height="49dp"
                     android:layout_width="wrap_content" 
                     android:layout_alignParentBottom="true" 
                     android:layout_alignParentLeft="true" 
                     android:layout_alignParentRight="true">
            <ImageView android:id="@+id/imageView1" 
                       android:src="@drawable/tabbar" 
                       android:layout_width="wrap_content" 
                       android:layout_height="wrap_content" 
                       android:scaleType="centerCrop"/>
        </FrameLayout>     
    </RelativeLayout>

</LinearLayout>

ScheduleScrollView表示されているのは、 2つの相対的なレイアウトを持つ水平スクロールビュー( )があることです。上の方にはタイムライン(ScheduleTimelineRelativeLayout)が含まれ、下の方(ScheduleConcertsRelativeLayout)にはプログラムで作成されたいくつかのボタンが含まれます。水平スクロールビューはタイムラインと同じ幅です。下の相対レイアウトで親を埋めたいのですが、これは水平スクロールビューと同じ幅である必要がありますが、これは機能しません。

私は自分の質問に対する答えを見つけようとしてこのフォーラムを検索しました。使用を提案する人もandroid:layout_width="match_parent"いますが、そうすると、次のエラーが発生します。

エラー:文字列タイプは許可されていません(値'match_parent'の'layout_width'で)

他の人は設定を提案しますandroid:layout_weight="1"が、これは何も変更しません(そして、設定は私のオートコンプリートで利用できないので、存在しないようです)

以下のスクリーンショットは私の問題を示しています。緑の部分は、私の水平スクロールビューの背景色です。これは表示されないはずです。代わりに、下の赤い部分が端に行く必要があります。

ここに画像の説明を入力してください

アップデート:

ここに画像の説明を入力してください

アップデート:

ScheduleConcertsRelativeLayoutレイアウトが配置された後にプログラムで幅と高さを設定することは機能しています。

RelativeLayout timeline = (RelativeLayout) findViewById(R.id.ScheduleTimelineRelativeLayout);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(timeline.getWidth(), scheduleConcertsRelativeLayout.getHeight());
params.setMargins(0, timeline.getHeight(), 0, 0);
scheduleConcertsRelativeLayout.setLayoutParams(params);
4

3 に答える 3

1

私はおそらくここで何かが欠けていますが、あなたは変更しようとしましたか?

<HorizontalScrollView android:id="@+id/ScheduleScrollView" android:layout_width="wrap_content" ... \>

<HorizontalScrollView android:id="@+id/ScheduleScrollView" android:layout_width="fill_parent" ... \>
于 2011-10-06T12:54:07.300 に答える
1

レイアウトが配置された後、ScheduleConcertsRelativeLayoutの幅と高さをプログラムで設定することは機能しています。

RelativeLayout timeline = (RelativeLayout) findViewById(R.id.ScheduleTimelineRelativeLayout);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(timeline.getWidth(), scheduleConcertsRelativeLayout.getHeight());
params.setMargins(0, timeline.getHeight(), 0, 0);
scheduleConcertsRelativeLayout.setLayoutParams(params);
于 2011-10-19T09:01:23.470 に答える
0

試着android:layout_width="fill_parent"しましたScheduleRelativeLayoutか?

于 2011-10-06T12:54:10.980 に答える