2016-06-24 5 views
0

私のListViewの行レイアウトをビルドして問題がある。 ImageViewの可視性を変更した後でTextviewが消える

は、現在、私のレイアウトは次のようになります。

enter image description here

XML:

:今、私はこの結果を得る android:visibility="gone"から imageView_albumartの可視性を変更したいとき

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout_ROW" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@null" 
     > 

    <ImageView 
     android:id="@+id/imageView_albumart" 
     android:layout_alignParentTop="true" 
     android:layout_width="70dp" 
     android:layout_height="70dp" 
     android:layout_marginRight="5dp" 
     android:background="@color/black" 
     android:visibility="visible" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <TextView 
     android:id="@+id/txt_titel" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/txt_artist" 
     android:layout_alignTop="@+id/imageView_albumart" 
     android:layout_toRightOf="@+id/imageView_albumart" 
     android:singleLine="true" 
     android:text="Titel" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_marginTop="18dp" 
     android:textSize="17dp" 
     android:layout_toLeftOf="@+id/imageView_eq_animation" 
     android:layout_alignLeft="@+id/txt_artist" 
     android:layout_alignStart="@+id/txt_artist" /> 

    <TextView 
     android:id="@+id/txt_artist" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/imageView_albumart" 
     android:layout_marginBottom="16dp" 
     android:layout_toRightOf="@+id/imageView_albumart" 
     android:text="Artist" 
     android:singleLine="true" 
     android:textSize="13dp" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_toLeftOf="@+id/imageView_eq_animation" /> 

    <ImageView 
     android:id="@+id/imageView_eq_animation" 
     android:layout_width="30dp" 
     android:layout_height="70dp" 
     android:src="@drawable/ic_equalizer1_white_36dp" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:visibility="gone" 
     android:layout_alignParentLeft="@+id/txt_artist" 
     android:layout_alignBottom="@+id/imageView_albumart" /> 

    <TextView 
     android:id="@+id/txt_length" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="0:00" 
     android:singleLine="true" 
     android:textSize="10dp" 
     android:visibility="gone" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_below="@+id/txt_titel" 
     android:layout_alignParentRight="true" /> 

</RelativeLayout> 

enter image description here

私のフォーマットの問題はどこにありますか?私はちょうどimgAlbumartを隠して、TitleとArtist TextViewsが単独で存在するようにしたい。

+1

したい場合は、 "目に見えない" 設定の視認性を試してみては画像を隠すがテキストは同じ位置にとどまる。 – danypata

+0

いいえ、私のtextviewsはalbumartがそこにないときに左に揃う必要があります。私はそれを不可能にすると、albumartは見えませんが、textviewsは同じ位置にあります。それは私が欲しいものではありません –

+0

タイトル** textview **はImageViewに依存しますpositon textview 'layout_alignBottom'と' layout_toLeftOf'のプロパティを参照してください。そうでなければ 'LinearLayout'を使用してください。 – Yugesh

答えて

0

あなたはRelativeLayoutとのLinearLayoutの組み合わせでUIを設計することができ、このようにしてください代わりにView.GONE

0

View.INVISIBLEにビューの可視性を設定します。 Androidのデザインパターンとレイアウトの使い方についてGoogleで検索します。あなたはアイデアを得るでしょう。

<?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="@null" 
android:orientation="horizontal"> 

<ImageView 
    android:id="@+id/imageView_albumart" 
    android:layout_width="70dp" 
    android:layout_height="70dp" 
    android:layout_margin="5dp" 
    android:background="@android:color/darker_gray" 
    android:visibility="visible" /> 

<RelativeLayout 
    android:id="@+id/RelativeLayout_ROW" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="5dp" 
    android:background="@null"> 

    <TextView 
     android:id="@+id/txt_titel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="20dp" 
     android:singleLine="true" 
     android:text="Titel" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textSize="17dp" /> 

    <TextView 
     android:id="@+id/txt_artist" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/txt_titel" 
     android:layout_marginBottom="16dp" 
     android:singleLine="true" 
     android:text="Artist" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textSize="13dp" /> 

    <ImageView 
     android:id="@+id/imageView_eq_animation" 
     android:layout_width="30dp" 
     android:layout_height="70dp" 
     android:layout_alignBottom="@+id/txt_artist" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentRight="true" 
     android:src="@drawable/ic_game" 
     android:visibility="gone" /> 

    <TextView 
     android:id="@+id/txt_length" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/imageView_eq_animation" 
     android:singleLine="true" 
     android:text="0:00" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textSize="10dp" 
     android:visibility="gone" /> 

</RelativeLayout> 
</LinearLayout> 
0

はい、あなたのレイアウトに問題がこれにあなたのレイアウトを変更 があります:それがどうなる

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/RelativeLayout_ROW" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
> 

<ImageView 
    android:id="@+id/imageView_albumart" 
    android:layout_width="70dp" 
    android:layout_height="70dp" 
    android:layout_marginRight="5dp" 
    android:background="#000" 
    android:visibility="gone" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

<TextView 
    android:id="@+id/txt_titel" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_toRightOf="@+id/imageView_albumart" 
    android:text="Titel" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:layout_marginTop="18dp" 
    android:textSize="17sp" 
    android:layout_toLeftOf="@+id/imageView_eq_animation" 
    /> 

<TextView 
    android:id="@+id/txt_artist" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/imageView_albumart" 
    android:layout_marginBottom="16dp" 
    android:layout_toRightOf="@+id/imageView_albumart" 
    android:text="Artist" 
    android:singleLine="true" 
    android:layout_below="@+id/txt_titel" 
    android:textSize="13dp" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:layout_toLeftOf="@+id/imageView_eq_animation" /> 

<ImageView 
    android:id="@+id/imageView_eq_animation" 
    android:layout_width="30dp" 
    android:layout_height="70dp" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" 
    android:visibility="visible" 
    android:layout_alignParentLeft="@+id/txt_artist" 
    android:layout_alignBottom="@+id/imageView_albumart" /> 

<TextView 
    android:id="@+id/txt_length" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="0:00" 
    android:singleLine="true" 
    android:textSize="10dp" 
    android:visibility="gone" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:layout_below="@+id/txt_titel" 
    android:layout_alignParentRight="true" /> 

..

関連する問題