FrameLayout with a TextView at the bottom

I have a framelayout like this. It contains two overlays:

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/my_frame" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/image_areas" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="fitCenter" android:src="@drawable/image_mask" android:visibility="invisible"/> <ImageView android:id="@+id/image" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="fitCenter" android:src="@drawable/walker"/> </FrameLayout> 

I want to add a TextView below this FrameLayout . Is it possible, or FrameLayout to take all the space on the screen? Can I put FrameLayout and TextView as LinearLayout ?

Edit: The problem is that my TextView does not appear when Im puts it in a LinearLayout or RelaiveLayout along with my FrameLayout.

+4
source share
2 answers

You can use RelativeLayout to store both your FrameLayout and TextView , and use the android:layout_above attribute in your android:layout_above . Something like that:

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout android:id="@+id/my_frame" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/TextViewId" > <ImageView android:id="@+id/image_areas" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="fitCenter" android:src="@android:drawable/alert_dark_frame" android:visibility="invisible" /> <ImageView android:id="@+id/image" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="fitCenter" android:src="@android:drawable/btn_dialog" /> </FrameLayout> <TextView android:id="@+id/TextViewId" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="TextView text" /> </RelativeLayout> 
+7
source
 <FrameLayout android:id="@+id/my_frame" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/image_areas" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitCenter" android:src="@android:drawable/alert_dark_frame" android:visibility="invisible" /> <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitCenter" android:src="@android:drawable/btn_dialog" /> <TextView android:id="@+id/TextViewId" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:text="layout_gravity is the key here..."/> </FrameLayout> 
+1
source

Source: https://habr.com/ru/post/1436636/


All Articles