How to put in the center 02 TextView of VideoView

0

I have 02 TextView and I want to put them in the center of a VideoView with one text being one on top of the other.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <VideoView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/videoView"
        android:layout_gravity="center_horizontal" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="30º C"
        android:layout_gravity="center_horizontal"
        android:textSize="28sp"
        android:id="@+id/Temperatura" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Notícias regionais"
        android:layout_gravity="center_horizontal"
        android:textSize="28sp"
        android:id="@+id/Notícia" />
</LinearLayout>
    
asked by anonymous 29.01.2018 / 02:00

2 answers

1

You can not set this in a LinearLayout because of the need to set the orientation of it. Change the LinearLayout for a RelativeLayout and add the attributes in the 2 textViews:

android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"

do as follows:

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/videoView" />
<TextView
    android:text="30º C"
    android:textSize="28sp"
    android:id="@+id/Temperatura"
    android:gravity="center"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />
<TextView
    android:text="Notícias regionais"
    android:textSize="28sp"
    android:id="@+id/Notícia"
    android:gravity="center"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/></RelativeLayout>
    
30.01.2018 / 12:00
0
  

You can use the RelativeLayout and put the attribute in the textview   android: layout_centerInParent="true"

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <VideoView
            android:id="@+id/videoView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="text view 1" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="text view 2" />

    </RelativeLayout>
    
01.02.2018 / 11:18