3

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="@android:color/transparent" >

    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_toLeftOf="@+id/weightLossIndicator"
        android:paddingLeft="15dp"
        android:paddingRight="10dp"
        android:orientation="vertical">

        <TextView 
            android:id="@+id/weightValueTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="10dp"
            android:textColor="@android:color/black"
            android:textSize="30sp"
            android:textStyle="normal" />

        <TextView 
            android:id="@+id/weightDateTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/black"
            android:textSize="20sp" />

        <TextView 
            android:id="@+id/weightDifferenceTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="10dp"
            android:textColor="@android:color/black"
            android:textSize="20sp" />

    </LinearLayout>

    <ImageView 
        android:id="@+id/weightLossIndicator"
        android:layout_width="10dp"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:background="@color/change_green"/>

    <View 
        android:id="@+id/separator"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/weightLossIndicator"
        android:layout_marginLeft="15dp"
        android:background="@color/dark_blue" />


</RelativeLayout>

ビューweightLossIndicatorは、レイアウト上の他の要素 (それらの位置) に影響しますが、デバイスとシミュレーターには表示されません。背景色は不透明で、グラフィカル レイアウトに表示されます。

更新: ImageView の固定の高さを 40 dp に設定しようとしましたが、それが表示されます。何か間違った使い方match_parentをしていますが、何がわかりません。ListViewまた、この XML を行レイアウトとして使用していると言わざるを得ません。

4

7 に答える 7

1

使用する必要があります

<LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@+id/weightLossIndicator"
    android:paddingLeft="15dp"
    android:paddingRight="10dp"
    android:orientation="vertical">

    <TextView 
        android:id="@+id/weightValueTextView"
        android:text="valueText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:textColor="@android:color/black"
        android:textSize="30sp"
        android:textStyle="normal" />

    <TextView 
        android:id="@+id/weightDateTextView"
        android:text="dateText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:textSize="20sp" />

    <TextView 
        android:id="@+id/weightDifferenceTextView"
        android:text="differencetext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="10dp"
        android:textColor="@android:color/black"
        android:textSize="20sp" />

</LinearLayout>

<ImageView 
    android:id="@+id/weightLossIndicator"
    android:layout_width="10dp"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="3dp"
    android:background="#00FF00"/>

<View 
    android:id="@+id/separator"
    android:layout_width="match_parent"
    android:layout_height="3dp"
    android:layout_alignParentBottom="true"
    android:layout_marginLeft="15dp"
    android:background="#0000FF" />

ここに画像の説明を入力

于 2013-10-07T13:02:49.693 に答える
0

レイアウト ファイル (コンテナ レイアウト BTW が欠落している) によると、これを達成したいことがわかります。

AB AB AC

ここで、A は LinearLayout (id はありません)、B は weightLossIndicator、C はセパレーターです。

これは正しいです?

その場合は、C を右下に配置し、B をその上に配置してから、A をどうするかを決定する必要があります。

また、B がまだ容量を確保できない場合は、代わりに ImageView を使用してみてください。

于 2013-09-23T22:47:21.553 に答える
0

WeightLossIndicator LinearLayout をに割り当ててみてLayoutWeightくださいandroid:layout_weight="1"

編集:

実は、あなたが兄弟観を持っていることに気付きました。ビューのレイアウト方法 (おそらく 50%/%50) に応じて、linearlayout と ImageView の両方を適用して使用できます。android:layout_weight="1"

再編集

コメントに示されているように、このシナリオは、LinearLayout 内に含まれる子レイアウトにのみ適用されます。

于 2013-09-30T20:17:32.903 に答える
0
// try this
<?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="match_parent"
              android:background="@android:color/transparent">
    <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingLeft="15dp"
            android:paddingRight="10dp"
            android:orientation="vertical">

        <TextView
                android:id="@+id/weightValueTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="10dp"
                android:textColor="@android:color/black"
                android:textSize="30sp"
                android:textStyle="normal" />

        <TextView
                android:id="@+id/weightDateTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@android:color/black"
                android:textSize="20sp" />

        <TextView
                android:id="@+id/weightDifferenceTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:textColor="@android:color/black"
                android:textSize="20sp" />

    </LinearLayout>

    <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="15dp"
            android:orientation="vertical">
        <ImageView
                android:id="@+id/weightLossIndicator"
                android:layout_width="10dp"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="@color/change_green"/>
        <View
                android:id="@+id/separator"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/change_green" />

    </LinearLayout>

</LinearLayout>
于 2013-10-04T04:04:31.167 に答える
0

最初に、大きなディスプレイを備えた別の avd を使用してみます。setvisible true コードでこの属性が false に設定されていますか? 相対的なレイアウトは扱いが難しく、見栄えが良くなっても、別のデバイスを使用すると、思い通りに表示されない可能性が高くなります。また android:src ="@drawable/mypic" 、描画可能なフォルダーに写真があることを確認してください

于 2013-10-07T17:48:49.493 に答える