2014-12-15 7 views
-2

Я хочу показать описание изображений в Viewflipper slidshow. Мне нужно добавить текстовое представление или кнопку на слайд-шоу viewflipper. Так что только я могу отображать описание изображения на основе текстового представления или кнопку click на viewflipper, это мой xmlДобавить Textview On Viewflipper

<?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:orientation="vertical" 
    android:scaleType="fitXY" > 

    <ViewFlipper 
     android:id="@+id/myflipper" 
     android:layout_width="match_parent" 
     android:layout_height="300dp" 
     android:gravity="center" 
     android:scaleType="fitXY" > 
    </ViewFlipper> 

</LinearLayout> 
+0

Почему бы вам не попробовать размещения ViewFlipper и TextView в FrameLayout? –

ответ

0

Вы можете использовать FrameLayout для размещения TextView над ViewFlipper, как показано здесь:

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/tools" 
    android:id="@+id/framelayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ViewFlipper 
     android:id="@+id/myflipper" 
     android:layout_width="match_parent" 
     android:layout_height="300dp" 
     android:gravity="center" 
     android:scaleType="fitXY" > 
    </ViewFlipper> 

    <TextView 
     android:id="@+id/mytext" 
     android:layout_width="match_parent" 
     android:layout_height="30dp"/> 

</FrameLayout> 

ЗАКАНЧИВАТЬ this образец программы блог для большего количества примеров того, как использовать FrameLayout.

День кодирование :)

+0

Спасибо за ваш ответ :) Это то, чего я хочу. –

0

Вы можете использовать с этим путем в вашем Layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_below="@+id/KeepToolbar" 
     android:orientation="vertical"> 

     <ViewFlipper 
      android:id="@+id/viewflipper" 
      android:layout_width="match_parent" 
      android:layout_height="150dp" 
      android:autoStart="true" 
      android:background="@color/ORANGE_700" 
      android:inAnimation="@anim/right_in" 
      android:outAnimation="@anim/left_out"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/a" /> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 

        <TextView 
         android:id="@+id/a" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="AAAA" /> 

        <TextView 
         android:id="@+id/e" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="asds" /> 

        <TextView 
         android:id="@+id/w" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="qweqw" /> 
       </LinearLayout> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/b" /> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 

        <TextView 
         android:id="@+id/b" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="BBBB" /> 

        <TextView 
         android:id="@+id/u" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="ssd" /> 

        <TextView 
         android:id="@+id/vb" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="wwee" /> 
       </LinearLayout> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/b" /> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 

        <TextView 
         android:id="@+id/c" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="CCCC" /> 

        <TextView 
         android:id="@+id/cd" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="asdfas" /> 

        <TextView 
         android:id="@+id/cf" 
         android:gravity="right" 
         android:layout_width="match_parent" 
         android:layout_height="30dp" 
         android:text="xxs" /> 
       </LinearLayout> 
      </LinearLayout> 

     </ViewFlipper> 
Смежные вопросы