2016-07-17 11 views
2

私がやっているのは、イメージビューの周りにテキストビューをラップして、イメージがイメージの左または右の面だけにならないようにすることです。 XMLでこれを行うことは可能ですか?それは画像を持つポップアップダイアログであるので、コードを使ってそれをやっていくと、クリックした内容に応じて複数の画像が表示されるため、苦労するでしょう。たとえば、画像を参照してください。Android Textviewラップイメージビュー

image

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:background="@android:color/background_light"> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:layout_margin="1dp" 
    android:background="@android:color/darker_gray"> 
    > 
    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <RelativeLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:layout_margin="20dp"> 

      <Button 
       android:id="@+id/dismiss" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Close" /> 

      <ImageView 
       android:id="@+id/IV1" 
       android:layout_width="100dp" 
       android:layout_height="100dp" 
       android:src="@drawable/IV1" 
       android:layout_below="@+id/dismiss" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/TV15" 
       android:id="@+id/TV15" 
       android:layout_below="@+id/dismiss" 
       android:layout_toRightOf="@+id/IV1" 
       android:layout_toEndOf="@+id/IV1" 
       android:paddingLeft="5dp" 
       android:paddingTop="5dp"/> 
     </RelativeLayout> 
    </ScrollView> 
</LinearLayout> 

答えて

0

使用FrameLayoutImageViewTextViewの順番を変更して、何が他のものになるかを設定します。

<FrameLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_centerInParent="true"> 

    <ImageView 
     android:id="@+id/menu_icon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:src="@mipmap/ic_launcher" /> 

    <TextView 
     android:id="@+id/menu_label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:lines="1" 
     android:text="this is my sample" /> 
</FrameLayout> 
+0

私はそれらをお互いの上に置いておきたいとは思いません。画像を見てください私は何をしようとしているのかの例を掲載しました。 – Jayce

+0

問題が誤解されましたが、このプロジェクトはhttps://github.com/deano2390/flowtextviewに役立ちます –