2017-09-20 2 views
0

私は以下のRelativelayoutを持っています。これにはラベル付き線形レイアウトが含まれています。このRelativelayoutはカスタムアダプターのカスタムListViewにプッシュされました。私はRelativelayouts一つ一つを見ると期待が、ターゲットのレイアウトはすべて、このように思えるthisリストビュー内のラショナルレイアウト

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:padding="8sp"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
    <TextView 
     android:text="Водомер 1" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingBottom="4sp" 
     android:layout_toRightOf="@id/linearLayout1" 
    <TextView 
     android:text="Последняя поверка:" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/linearLayout1" 
    <TextView 
     android:text="Последние показания:" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/linearLayout1" 
    <TextView 
     android:text="Текущие показания:" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/linearLayout1" 
    </LinearLayout> 
    <ImageView 
     android:src="@android:drawable/ic_menu_gallery" 
     android:layout_width="76sp" 
     android:layout_height="76sp" 
     android:paddingRight="13sp" 
     android:layout_alignParentRight="true" 
</RelativeLayout> 

を得ました。そして、このListViewに他のカスタムビューを設定しても、うまく見えます。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:columnCount="1" 
    app:rowCount="7"> 
    <TextView 
     android:text="Список водомеров" 
     android:layout_width="match_parent" 
     app:layout_rowWeight="0.05" 
     android:gravity="center_horizontal"/> 
    <ListView 
     android:minWidth="25px" 
     android:minHeight="25px" 
     app:layout_rowWeight="0.3" 
     android:layout_width="match_parent" 
     android:choiceMode="singleChoice" /> 
    <TextView 
     android:text="Введите показания водомера" 
     app:layout_rowWeight="0.02" 
     android:layout_width="match_parent" 
     android:gravity="center" /> 
    <EditText 
     android:inputType="number" 
     app:layout_rowWeight="0.04" 
     android:layout_width="match_parent"/> 
    <Button 
     android:text="Сделать фото" 
     android:textSize="20dp" 
     app:layout_rowWeight="0.02" 
     android:layout_width="match_parent" 
     android:gravity="center"/> 
    <Button 
     android:text="Отправить показания" 
     android:textSize="24dp" 
     app:layout_rowWeight="0.15" 
     android:layout_width="match_parent" 
     android:gravity="center"/> 
    <Space 
     app:layout_rowWeight="0.3" /> 
</android.support.v7.widget.GridLayout> 

これをどのように修正できますか?

+1

なぜあなたはrecyclerViewを使用しないのですか?これは問題のための最良の解決策です。 [this](https://www.androidhive.info/2016/01/android-working-with-recycler-view/)を見てみると分かります。 –

+0

私はListViewの上にあるTextViewから問題が発生すると思います。開発者オプションの[レイアウトの表示]機能を有効にして、問題の原因となるビューを表示できるようにする必要があります。 「レイアウトの表示」を有効にする方法については、こちらをご覧ください:https://www.youtube.com/watch?v=OGqJhK0FTjwそれは助けることを望む –

+0

@LQGioanうん、それはコップチップです。だから、私の行はListViewではなくTextViewに追加されました – NisuSan

答えて

0

としてリストの上のTextViewの高さを設定します。コンテンツ要素では、layout_weightプロパティを使用しています。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:weightSum="100"> 
<TextView 
     android:text="Список водомеров" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_horizontal" 
     android:layout_weight="11" 
     android:id="@+id/textView1" /> 
0

は私がLQ Gioanの助言を使用してweightSumプロパティでのLinearLayoutにターゲットのGridLayoutを交換私の問題を解決するためにwrap_content

関連する問題