I have FrameLayout like this:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="changeColor"
android:text="new button"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text"/>
</FrameLayout>
The problem is that the button is displayed on top while FrameLayout class overview tells us this: "Child views are drawn in a stack, with the most recently added child on top".
Update:
in android 21+ after introduction of elevation one can play with elevation attribute of various widgets to put them on top of one another. here is a material design guide for elevation values.
for api < 21 :
This answer
Buttons in Lollipop and higher have a default elevation to them which
causes them to always draw on top. You can change this by overriding
the default StateListAnimator.
Try putting this into your button XML:
android:stateListAnimator="#null"
The FrameLayout should now cover the
button.
In the Android 5.0 (API 21) and above, you must add android:elevation into the view.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="changeColor"
android:text="new button"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text"
android:elevation="3dp"/>
Put your Button inside FrameLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new button" />
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text" />
</RelativeLayout>
As the official android documantation points out:
FrameLayout is designed to block out an area on the screen to display
a single item. Generally, FrameLayout should be used to hold a single
child view, because it can be difficult to organize child views in a
way that's scalable to different screen sizes without the children
overlapping each other. You can, however, add multiple children to a
FrameLayout and control their position within the FrameLayout by
assigning gravity to each child, using the android:layout_gravity
attribute.
It's better if you put your Button and Textview in a RelativeLayout inside the FrameLayout like:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text"/>
<Button
android:id="#+id/button1"
android:layout_below="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="changeColor"
android:text="new button"/>
<RelativeLayout>
</FrameLayout>
Apperently android:stateListAnimator="#null" works only for API = 21 or higher,
So for those who target API<21 use this, it worked for me :D
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="changeColor"
android:text="new button"/>
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text"/>
</FrameLayout>
FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.
You should use LinearLayout or RelativeLayout in FrameLayout .
Like this way
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="changeColor"
android:text="new button"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text"/>
</RelativeLayout>
</FrameLayout>
For API < 21 you cant use android:stateListAnimator="#null" or change the elevation. In my case I used 2 frame layouts embedded in a constraint layout.
As the frame layouts can be stacked upon each other there is no need to change the elevation of the textview.
<android.support.constraint.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<Button
android:id="#+id/my_daybutton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/cal_button_background"
android:textColor="#color/colorPrimaryDark"
android:gravity="start|top"
android:paddingTop="2dp"
android:paddingStart="2dp"
android:paddingEnd="2dp"
/>
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bla"
android:textSize="9sp"
android:textColor="#android:color/holo_red_dark"
android:layout_gravity="bottom|end"
/>
</FrameLayout>
Just put elevation FrameLayout or any parent there you are going to load you fragment like
android:elevation="#dimen/dimen_20"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="#dimen/dimen_0"
android:id="#+id/ready_to_scan"
app:layout_constraintTop_toTopOf="parent"
android:elevation="#dimen/dimen_20"
app:layout_constraintBottom_toBottomOf="parent"/>
Related
So, I would like to add a button with the text "Already Registered?" on the middle bottom screen but my code contains a two different LinearLayouts for the half left and the half right side. I want the button to be half on the left Linearlayout and half on the right. In addition, they are clickable so as far as I concern I must have them in my current layout and not include them.
what I currently have:
What I want to get:
my code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
tools:context=".MainActivity"
android:weightSum="2"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/customerLinearLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_weight="1"
android:background="#color/lightblueMainActivity"
android:onClick="customerSignUp">
<TextView
android:layout_gravity="center_vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textColor="#color/orangeMainActivity"
android:text="#string/customerMainActivity"/>
</LinearLayout>
<LinearLayout
android:id="#+id/electricianLinearLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_weight="1"
android:background="#color/orangeMainActivity"
android:onClick="electricianSignUp">
<TextView
android:layout_gravity="center_vertical"
android:gravity="center"
android:textSize="24sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/lightblueMainActivity"
android:text="#string/electricianMainActivity"/>
</LinearLayout>
</LinearLayout>
THANKS IN ADVANCE!
There are other types of ViewGroup besides LinearLayout which allow you to achieve a "split screen" effect, but let's keep it simple and use a weighted LinearLayout to divide the screen.
The child Views however can be TextViews (no intermediate ViewGroup required) because you can let them have a background color and also control the text alignment.
Since you want the Button to overlap both parts of the screen, you can put it and the LinearLayout into a FrameLayout (I used a TextView but the attributes are basically the same):
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="Customer"
android:textColor="#aaaaaa"
android:textSize="20sp"
android:gravity="center"
android:background="#0000ff"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="Electrician"
android:textColor="#666666"
android:textSize="20sp"
android:gravity="center"
android:background="#ffab00"/>
</LinearLayout>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="24dp"
android:textColor="#ffffff"
android:textSize="20sp"
android:text="Already Registered?"/>
</FrameLayout>
I am trying to place a relativelayout under another (with recyclerview in it) within an activity layout container.
What I'd like to get is to have the action bar, then below a relativelayout with header (showing a spacer and 2 textviews), and below again another relativelayout that will host cards from a recyclerview.
This is the image of the wanted design:
What I get instead is this:
I am using the following xml (but tried many others)
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="#style/Theme.AppCompat.Light">
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
tools:ignore="UselessParent">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:contentDescription="image"
android:scaleType="centerCrop"
android:src="#drawable/category_detail_1" />
<TextView
android:id="#+id/spacer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:text=""
android:textColor="#fff"
android:textSize="25sp" />
<TextView
android:id="#+id/sub_header_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/spacer"
android:background="#66555555"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:text=""
android:textColor="#fff"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/sub_header_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/sub_header_title"
android:background="#66555555"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:text=""
android:textColor="#fff"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/button_container"
android:layout_width="395dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/header"
tools:ignore="UselessParent">
<android.support.v4.widget.Space
android:layout_width="#dimen/default_spacing_small"
android:layout_height="#dimen/default_spacing_small" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
I tried to put the second RelativeLayout nested as a child of the first one with no luck.
The Android Studio preview shows the design well formatted but after build the card list overlaps the header. Well formatted apart from the unknown line/constraint I do not know how to remove. It constraints the second relativelayout to the top.
What am I missing?
Any help is appreciated.
Use FrameLayout instead of android.support.constraint.ConstraintLayout
Or try with LinearLayout
How can i position floating button above Scrollview layout...i have tried to position Scrollview and the container of the button(FrameLayout) inside Relative layout but this approach also is not working...
xml file:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100">
<ScrollView
android:layout_width="match_parent"
android:layout_height="#dimen/no_size"
android:layout_weight="92">
<LinearLayout
android:id="#+id/questionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.rey.material.widget.TextView
android:id="#+id/surveyTitleTtv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#android:color/black" />
<com.rey.material.widget.TextView
android:id="#+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:layout_marginBottom="12dp"
android:textColor="#color/accentColor"
android:textSize="17dp"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<FrameLayout
android:id="#+id/bottomSheetLlt"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="8"
android:background="#android:color/white">
<com.rey.material.widget.FloatingActionButton
android:id="#+id/saveQuestionBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="-20dp"
android:text="ADD"
app:elevation="2dp" />
</FrameLayout>
Please can anyone tell me what's going wrong?
Finally i have managed to resolve the issue..the problem was that i was trying to place FAB inside fragment layout which obviously turned out to be not feasible. I moved it inside my activity xml layout as a child of CoordinatorLayout and now is actually a 'floating' action button...
Just move your FloatingButton above scroll view in xml layout
You need to position a FloatingActionButton within a CoordinatorLayout and use the CoordinatorLayout as the root of your Activity. (FloatingActionButton relies on features which the CoordinatorLayout enables) If your scrollview is a inside a fragment, this is still alright - so long as you assign an ID to the FloatingActionButton you can reference it from inside the fragment.
Replace your xml code with below code. You need to use Relative Layout or Coordinator Layout as root layout. And simply put floatig action button outside of framelayout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/questionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.rey.material.widget.TextView
android:id="#+id/surveyTitleTtv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:textColor="#android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<com.rey.material.widget.TextView
android:id="#+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:textColor="#color/accentColor"
android:textSize="17dp"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<com.rey.material.widget.FloatingActionButton
android:id="#+id/saveQuestionBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|right|end"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="ADD"
app:elevation="2dp" />
I have a FrameLayout that consists of a list view and a button. The whole point of the FrameLayout is that elements that are after other elements will be displayed above them.
Since the button code is below the ListView code, I expected the button will always be on top, but it isn't. I can't figure it out - as soon as I get enough items in my list, the button is underneath it and it becomes obsolete.
XML:
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/lvMovies"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#fff"
android:elevation="3dp"
android:paddingTop="8dp" />
<Button
android:id="#+id/btnAddMovie"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/raised_action_button"
android:elevation="5dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="+"
android:textColor="#ffffff"
android:textSize="30sp" />
</FrameLayout>
From developer.android:
FrameLayout is designed to block out an area on the screen to display
a single item. Generally, FrameLayout should be used to hold a single
child view,
The current dimensions of the framelayout is the entire screen. If I was to use the entire screen for the above layout I would do something like the following:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:orientation="horizontal">
<ListView
android:id="#+id/lvMovies"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#fff"
android:elevation="3dp"
android:paddingTop="8dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="#+id/btnAddMovie"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:background="#drawable/raised_action_button"
android:elevation="5dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="+"
android:textColor="#ffffff"
android:textSize="30sp" />
</LinearLayout>
</LinearLayout>
You can say 0dp weight for either a height or a width, but not both. You then team it up with a layout_weight. In this case the first nested linear layout takes up 5/6ths of the screen, the second 1/6th. Thus your button sits in a protected space that the list view will not block out.
The outer linear layout has a vertical orientation which makes the two inner layouts stack on top of each other, the inners are horizontal to make them go across the entire screen. You will need to tweak those weights to make it work for you.
You can use RelativeLayout for this. If you want button view over the listview android:layout_above="#+id/btnAddMovie" delete this line.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/lvMovies"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/btnAddMovie"
android:layout_marginBottom="8dp"
android:background="#fff"
android:elevation="3dp"
android:paddingTop="8dp" />
<Button
android:id="#+id/btnAddMovie"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:elevation="5dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="+"
android:textColor="#ffffff"
android:textSize="30sp" />
</RelativeLayout>
Remove the elevation property from the list view. That's it.
It seems like the elevation causes the element to be on top of other elements.
I have stuck in some xml code and i hope you can help me out.
So here is what I need/what I have done by now.
I have 3 images of 650px width and I need them one below another while keeping aspect ratio.
I did that with the following code and it looks as it should. No problem here.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ll"
android:orientation="vertical"
android:background="#3afa3f"
android:weightSum="3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/krk_history"
android:layout_weight="1"
android:background="#drawable/povjestkrka_vintage_yellow600" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/krk_frankopan"
android:background="#drawable/frankopan2_vintage_sundown600" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/krk_turizam"
android:background="#drawable/krk_turizam_vintage"/>
The problem is. I need to put three textviews in a left bottom corner of each image. Imagine it like image menu with text description on each image.
So, I can not use relative or frame layout because images won't play nicely with each other :) There is always a gap between or not aspect ration etc. I need weightsum.
Second, I can't hardcode the text on each image in photoshop because the app will be translated and text needs to change for each language.
I can have different images for each language but I am trying to avoid that.
Ah yea, one more last thing.
I tried to put entire linearlayout in relative layout and put the text between but the text appears beneath the image and I can't bring it upfront.
Any suggestions?
Thanks a lot,
Xsonz
just copy this :
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:padding="5dp"
android:text="Text 1" />
</FrameLayout>
<FrameLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:padding="5dp"
android:text="Text 2" />
</FrameLayout>
<FrameLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:id="#+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:padding="5dp"
android:text="Text 3" />
</FrameLayout>
Take three FrameLayout inside your LinearLayout and inside FrameLayout keep the ImageView and TextView.
Or Else You can use RelativeLayout and give dependency to Views
You can use frame layout inside linear layout. create imageview inside the linear layout and create textview in another frame layout below it.
<FrameLayout
android:id="#+id/frameLayout_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/krk_history"
android:layout_weight="1"
android:background="#drawable/povjestkrka_vintage_yellow600" />
</FrameLayout>
<FrameLayout
android:id="#+id/frameLayout_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-5dp" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="string" />
</FrameLayout>
Something like this might work for you.
//your layout -> LinearLayout>
....
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/image1"
android:layout_weight="1"
android:background="#drawable/A1" />
<TextView android:id="#+id/textview1"
android:layout_margin="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Text"
android:layout_below="#id/image1"
android:layout_alignLeft="#id/image1" />
</RelativeLayout>
// end your LinearLayout
You can play with these parameters using Relative Layout Parameters android.com. The relative layout allows you to control the "relative" positioning between your elements.
You can lay your images out side by side, or in whatever fashion you wish.
Then you can adjust the text dynamically.