Wednesday, 12 August 2015

android display text on top of your image



If you want to implement a page like this:






Please use FrameLayout.


This is my layout file:


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        tools:context="com.marksandspencer.gonzales.views.BigImageActivitiy"
        android:orientation="vertical"
        android:gravity="center_horizontal">

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/big_image_product_image"
        android:scaleType="fitStart"
        />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="#32010101">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="type"
            android:id="@+id/big_image_product_type"
            android:textColor="#ffffff"
            android:layout_marginTop="5dp"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="name"
            android:id="@+id/big_image_product_name"
            android:textColor="#ffffff"
            android:layout_marginTop="10dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Description"
            android:id="@+id/big_image_product_description"
            android:textColor="#ffffff"
            android:layout_marginTop="10dp" />
    </LinearLayout>

</FrameLayout>









http://etcodehome.blogspot.co.uk/2011/05/android-imageview-scaletype-samples.html

http://etcodehome.blogspot.co.uk/2011/05/android-imageview-scaletype-samples.html
http://etcodehome.blogspot.co.uk/2011/05/android-imageview-scaletype-samples.html
http://etcodehome.blogspot.co.uk/2011/05/android-imageview-scaletype-samples.html
http://etcodehome.blogspot.co.uk/2011/05/android-imageview-scaletype-samples.html
http://etcodehome.blogspot.co.uk/2011/05/android-imageview-scaletype-samples.html

Here is a table showing samples for all scale types for the ImageView.

scaleTypefill_parent x fill_parent200dp x 200dp200dp x 200dp
with Overlay
matrix
fitXY
fitStart
fitCenter
fitEnd
center
centerCrop
centerInside































No comments:

Post a comment