2015-03-30 6 views
0

В моем макете я показываю изображение и на этом изображении я показываю текстовое изображение внизу. Его работа отлично. мой код:Textview Before imageview в FrameLayout

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:minHeight="210dp" 
android:padding="12dp"> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="210dp" 
    android:id="@+id/imageViewNews" 
    android:src="@mipmap/img_splash"/> 

<com.mynews.widgets.TextViewRobotoBold 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal|bottom" 
    android:id="@+id/textViewNewsTitle" 
    android:background="#CCd3d3d3" 
    android:padding="12dip" 
    android:textColor="@color/color_primary_text_color" /> 

Теперь я хочу, чтобы отобразить один TextView перед этим изображением (не по изображению) Как это сделать? Я попытался, но это не отображение. Когда я использую relativelayout, ничего не отображается. Пожалуйста, предложите мне показать текстовое изображение перед просмотром изображения в приведенном выше коде.

Я также попытался использовать RelativeLayout как:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:minHeight="210dp" 
android:padding="12dp"> 

<com.mynews.widgets.TextViewRobotoBold 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal|top" 
    android:id="@+id/textViewTimeTitle" 
    android:background="#CCd3d3d3" 
    android:text="Last updated Time is:" 
    android:padding="12dip" 
    android:textColor="@color/color_primary_text_color" /> 

<ImageView 
    android:layout_below="@+id/textViewTimeTitle" 
    android:layout_width="match_parent" 
    android:layout_height="210dp" 
    android:id="@+id/imageViewNews" 
    android:src="@mipmap/img_splash"/> 

<com.mynews.widgets.TextViewRobotoBold 
    android:layout_width="wrap_content" 
    android:layout_below="@+id/imageViewNews" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal|bottom" 
    android:id="@+id/textViewNewsTitle" 
    android:background="#CCd3d3d3" 
    android:padding="12dip" 
    android:textColor="@color/color_primary_text_color" /> 

Now Первый TextView дисплеях перед изображением, которое является то, что я хочу. Но последний (второй) текстовый дисплей ниже изображения. Я хочу, чтобы он смотрел снизу вверх.

Любое предложение будет оценено по достоинству. Заранее спасибо.

+0

просмотры за детьми втягиваются в стеке, с последним добавленным ребенком на top.http: //developer.android.com/reference/android/widget/FrameLayout.html. Так что если вам нужно textview сначала, то есть textview выше imageview в xml. RelativeLayout также может использоваться. Это зависит от того, что вы хотите. – Raghunandan

+0

@Raghunandan Я не хочу textview над imageview. Я хочу, чтобы texview под этим текстовым представлением отображал мое изображение, а над этим изображением - одно текстовое изображение внизу. – PPD

+2

Использование RelativeLayout было бы лучшим вариантом. Поместите текстовое изображение относительно изображения. – Raghunandan

ответ

0

Использование Relativelayout в качестве предложения работ Рагхунандана.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:minHeight="210dp" 
android:padding="12dp"> 

<com.mynews.widgets.TextViewRobotoBold 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal|top" 
    android:id="@+id/textViewTimeTitle" 
    android:background="#CCd3d3d3" 
    android:text="Last updated Time is:" 
    android:padding="12dip" 
    android:textColor="@color/color_primary_text_color" /> 

<ImageView 
    android:layout_below="@+id/textViewTimeTitle" 
    android:layout_width="match_parent" 
    android:layout_height="210dp" 
    android:id="@+id/imageViewNews" 
    android:src="@mipmap/img_splash"/> 

<com.mynews.widgets.TextViewRobotoBold 
    android:id="@+id/textViewNewsTitle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/imageViewNews" 
    android:gravity="bottom" 
    android:layout_gravity="center_horizontal|bottom" 
    android:layout_centerInParent="true" 
    android:background="#CCd3d3d3" 
    android:padding="12dip" 
    android:textColor="@color/color_primary_text_color" /> 

0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="240dp" 

android:padding="12dp"> 

<com.mynews.widgets.TextViewRobotoBold 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal|top" 
    android:id="@+id/textViewTimeTitle" 
    android:background="#CCd3d3d3" 
    android:text="Last updated Time is:" 
    android:padding="12dip" 
    android:textColor="@color/color_primary_text_color" /> 

<ImageView 
    android:layout_below="@+id/textViewTimeTitle" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    android:id="@+id/imageViewNews" 
    android:src="@mipmap/img_splash"/> 

<com.mynews.widgets.TextViewRobotoBold 
    android:layout_width="wrap_content" 
    android:layout_alignBottom="@+id/imageViewNews" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal|bottom" 
    android:id="@+id/textViewNewsTitle" 
    android:background="#CCd3d3d3" 
    android:padding="12dip" 
    android:textColor="@color/color_primary_text_color" /> 
Смежные вопросы