Frame Layout Examples



Frame Layout Example - Text above Image


Replace my_picture in the activity_main.xml, with the picture you add in the drawable folder.


MainActivity.java

package com.zyasin.framelayout;

import android.os.Bundle;

import android.app.Activity;

public class MainActivity extends Activity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
}




activity_main.xml

<FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView
        android:src="@android:drawable/my_picture"
        android:scaleType="fitCenter"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"/>
    <TextView
        android:text="zyasin.com"
        android:textSize="24sp"
        android:textColor="#ffff"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:gravity="center"/>
</FrameLayout>


Tweet  




Copyright (c) Zafar Yasin. All rights reserved.