I have a listview which contains a linearlayout. I am trying to get the linearlayout to the center of the screen(horizontally) but it doesn't work.
How it looks -
Portrait -
Landscape -
I want the linearlayout(which has the text "text" and the two images) to come to the center of the screen(horizontally) in both the orientations.
I've tried using layout_gravity on the linearlayout but it doesn't work.
Here's my code -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EEEEEE" >
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/parentListContainer">
</ListView>
</LinearLayout>
Each listview item -
<?xml version="1.0" encoding="utf-8"?>
<!-- I want this layout centered. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textColor="#000000"
android:text="text"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle1"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Please help.
EDIT: Neither gravity="center" works on the listview, nor does layout_gravity="center" on the linearlayout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#EEEEEE" >
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/parentListContainer">
</ListView>
</LinearLayout>
See here for explanation : https://stackoverflow.com/a/3482757/4706693
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textColor="#000000"
android:text="text"/>
<LinearLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle1"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/ivBottle2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvBottle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textSize="22sp" >
</TextView>
</LinearLayout>
</LinearLayout>
Related
how i can set my items to full screen of all device,
i have RecyclerView and CardView for horizontal and vertical listview
singleitems.xml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
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="horizontal"
app:cardCornerRadius="5dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_az"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_be"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_tripCondition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_tripCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_tripDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
main_items.xml :
<?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="wrap_content"
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="5dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_list"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center_vertical"
android:gravity="right"
android:orientation="horizontal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:background="#android:color/holo_green_dark">
<TextView
android:id="#+id/itemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_toLeftOf="#+id/btnMore"
android:text="Sample title"
android:textColor="#android:color/white"
android:textSize="18sp" />
<Button
android:id="#+id/btnMore"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="More" />
</RelativeLayout>
and i use like this in my activity_main.xml :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.software.mahoo.operator.Activityes.Act_Request">
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:gravity="right"/>
with this code my item is like this picture :
i want fit to all device fullscreen like this picture :
items is horizontal , and with swipe to right item change scroll to next item .
how i can do this ?
I want to design following design in android using Linear layout
I had written following code but not working
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_weight="1"
android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="1" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:text="TextView" android:layout_weight="1" />
<TextView
android:id="#+id/textView2" android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentRight="true"
android:text="TextView" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" android:hint="TestData"/>
</LinearLayout>
</LinearLayout>
it gives me output like
can anyone pointout me.. where is problem???
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="dfasdfasdfasfasf" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="07 DEc" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dskfhasjkldfhadjklsfhadjklsfhajkldfhadjklsfhajklsfhajklsdfhajklsdfhajklsdfhajkldf" />
</LinearLayout>
</LinearLayout>
This will work... :)
This will work for you.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:padding="5dip" >
<ImageView
android:id="#+id/icon"
android:layout_width="70px"
android:layout_height="50px"
android:layout_marginRight="3dip"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/toptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="dsggsdggfsgf"
android:textColor="#000000"
android:textSize="16px"
android:textStyle="bold" />
<TextView
android:id="#+id/datetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:maxLines="1"
android:text="1 dec 2012"
android:textColor="#cccccc"
android:textSize="12px"
android:textStyle="bold" />
</RelativeLayout>
<TextView
android:id="#+id/bottomtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdf"
android:textColor="#696969"
android:textSize="12px" />
</LinearLayout>
</LinearLayout>
I think you can use relativelayout at first level, like the following:
<relativelayout>
<imageview align to parent top, left, bottom>
<linearlayout align to parent to, right, right to image view>
<textview1/>
<textview2/>
</linearlayout>
<textview align to parent bottom, right, righto to image view, below linearlayout>
</relativelayout>
This should work. But it will be better if you use RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="TestData"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_weight="1"
android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="3"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame"
android:layout_weight="2"/>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hfdfhfj" android:layout_weight="2" />
<TextView
android:id="#+id/textView2" android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6 Dec 2012" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fkjfkdsnfdsnfkdsn\nmnfkfknfkdf\nfknf" android:hint="TestData"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try this code.it is exactly what you want.
I am facing a strange behavior of text view. When the text view has multiple lines, the lines are overlapping on each other. I tried to solve it but didn't get any clue yet.
Here is the XML:
<?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="fill_parent"
android:background="#drawable/googletv_bkgd_no_title"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="85dip"
android:gravity="center_vertical"
android:orientation="horizontal" >
<FrameLayout
android:id="#+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent" android:paddingRight="50dip">
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:gravity="center_vertical">
<TextView
android:id="#+id/navigationHeaderTxtView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#cccccc"
android:visibility="gone" android:layout_gravity="center_vertical"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_gravity="left|center_vertical" android:layout_marginLeft="5dip" android:textColor="#ebebee" android:textStyle="bold"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
<!--
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="top|right" android:layout_marginRight="20dip">
<Button
android:id="#+id/btnBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:background="#drawable/btn_back" />
<Button
android:id="#+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:background="#drawable/btn_home" />
</LinearLayout>-->
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_gravity="top" android:layout_marginTop="20dip" android:gravity="center">
<ImageView
android:id="#+id/arrow_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow_up" android:visibility="visible"/>
</LinearLayout>
<FrameLayout
android:id="#+id/frameLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:paddingLeft="80dip" android:paddingRight="80dip">
<GridView
android:id="#+id/gridView1"
android:layout_width="match_parent"
android:layout_height="250dip"
android:cacheColorHint="#00000000"
android:horizontalSpacing="10dip"
android:listSelector="#drawable/list_selector"
android:numColumns="5"
android:padding="10dip"
android:verticalSpacing="10dip" >
</GridView>
</FrameLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:layout_gravity="top" android:layout_marginTop="20dip" android:gravity="center">
<ImageView
android:id="#+id/arrow_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow_down" android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:id="#+id/frameLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/title_color"
android:textSize="25dip" android:layout_gravity="center_horizontal"/>
<TextView
android:id="#+id/textDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
I have attached a screenshot regarding the problem.
How do I fix this?
You will need to adjust your line spacing to accommodate the odd custom font, such as android:lineSpacingExtra on your TextView.
i have a layout made in xml for an android app. The last textview it is not shown. why? what can i do? i try setting the linearlayout with height : fill_parent, wrap_content and match_parent:
this is the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#drawable/sfondo">
<LinearLayout android:id="#+id/linearLayout2"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:orientation="vertical">
<LinearLayout android:id="#+id/linearLayout1"
android:layout_height="fill_parent" android:weightSum="1"
android:layout_width="fill_parent" android:orientation="horizontal">
<ImageButton android:id="#+id/back1" android:src="#drawable/back"
android:background="#null" android:layout_marginTop="25dip"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</ImageButton>
<ImageView android:layout_height="wrap_content" android:id="#+id/logoTC"
android:src="#drawable/trovachiavi_contatti" android:layout_width="wrap_content"
android:layout_marginTop="20dp">
</ImageView>
<ImageButton android:id="#+id/infoButton"
android:background="#null" android:layout_height="wrap_content"
android:layout_marginTop="10dip" android:src="#drawable/info_mini"
android:layout_width="wrap_content"></ImageButton>
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="fill_parent" android:id="#+id/layoutGif1"
android:orientation="vertical">
<spazio.digitale.com.GIFView
android:layout_gravity="center" android:layout_width="wrap_content"
android:layout_height="220dp" android:id="#+id/GIFMulti"
android:layout_marginLeft="40dp"></spazio.digitale.com.GIFView>
<TextView android:layout_height="wrap_content" android:id="#+id/testoAiuto"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content" android:gravity="center"
android:textColor="#android:color/black" android:layout_marginTop="-210dp"></TextView>
<ImageButton android:layout_gravity="center|bottom"
android:layout_width="wrap_content" android:layout_marginTop="25dp"
android:layout_height="wrap_content" android:background="#null"
android:id="#+id/avvia_cerca"></ImageButton>
<TextView android:layout_width="match_parent" android:id="#+id/testoRicercaMulti"
android:layout_height="wrap_content" android:textColor="#android:color/black"
android:textSize="14dp" android:gravity="center"
android:layout_gravity="center" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
</TextView>
</LinearLayout>
It looks to me like your layout just isn't fitting. Wrap your views in a ScrollView, for example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#drawable/sfondo">
...
<ScrollView android:id="#+id/scroll" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent" android:id="#+id/testoRicercaMulti"
android:layout_height="wrap_content" android:textColor="#android:color/black"
android:textSize="14dp" android:gravity="center"
android:layout_gravity="center" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
</TextView>
</ScrollView>
</LinearLayout>
Hope that helps!
your layout doesn't fit on your screen. wrap your main LinearLayout inside a ScrollView.
I have a layout problem, the idea is that the buttons and text dont show
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#5094c5"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingTop="8dp" >
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<ImageButton
android:id="#+id/buton_produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/icon" />
<TextView
android:id="#+id/produse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Produse"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Set the height and width in the xml layout file to what they should be when they are visible but initially, in code, get a reference to them and make them invisible. Then, when needed, you can make them visible (in code).
Maybe better try with RelativeLayout. This seems to be too nested and too much complicated than it suppose to be.
You can give setVisibility() property to button and textview in layout.