Hi have a app with a actionbar sherlock and a listview that shows 1 imageview and 2 textviews, but the actionbar blocks the first row in listview. (See image here)
This is the code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/settings"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="538dp"/>
</LinearLayout>
and the row.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="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.17"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" >
<ImageView
android:id="#+id/iNavigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10px"
android:paddingTop="10px"
android:src="#drawable/llevame" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/linearLayout3"
android:orientation="vertical" >
<TextView
android:id="#+id/nombreTienda"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="12px"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</RelativeLayout>
<TextView
android:id="#+id/dirTienda"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10px"
android:paddingTop="30px"
android:text="TextView"
android:textSize="15px" />
</LinearLayout>
</LinearLayout>
I have other activity same of this and dont happen this..Why?
It appears as though the action bar is overlapping your gallery. Try adding:
android:layout_marginTop="?android:attr/actionBarSize"
To your "settings" LinearLayout. Without seeing your other Activity's XML, it's difficult to say why it's not happening there.
Related
I have a ViewPager which shows Fragments and I want that on the top, and a simple LinearLayout on the bottom. But, the Fragments are overlapping the layout at the bottom. I want the Fragment to end right about the LinearLayout. See picture:
XML with ViewPager
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="#+id/steps_pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/finish_checklist_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_white_glossy"
android:layout_margin="20dp"
android:text="#string/finish_checklist" />
</LinearLayout>
XML of Fragment
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:background="#fff" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="26sp"
android:text="#string/step_order_label" />
<TextView
android:id="#+id/step_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="26sp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#000" />
<TextView
android:id="#+id/step_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="26sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="40dp"
android:textSize="20sp"
android:text="#string/result_label" />
<TextView
android:id="#+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" />
</LinearLayout>
<!-- YES/NO BUTTONS -->
<Button
android:id="#+id/button_no"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/btn_white_glossy"
android:padding="20dp"
android:visibility="gone"
android:text="#string/button_no" />
<Button
android:id="#+id/button_yes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/button_no"
android:background="#drawable/btn_white_glossy"
android:padding="20dp"
android:layout_marginBottom="30dp"
android:visibility="gone"
android:text="#string/button_yes" />
<!-- END YES/NO BUTTONS -->
I used android:layout_below element here.
layout_below your ViewPager id.
and this layout as vertical
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="fill_vertical"
android:orientation="vertical" >
In all your xml files, should define the background color for it, it will solve the problem :
Add this android:background="#android:color/black" in to the View tag you defined.
p/s : This case only avoid Background was overlapped.
In the following piece of code the Linear Layout at the extreme bottom is not visible.I tried several methods but couldn't make it visible.Please take a look
<?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:background="#color/GlobalBG"
android:orientation="vertical" >
<include
android:id="#+id/id_nav_bar"
layout="#layout/app_nav_layout" />
<ListView
android:id="#+id/id_home_screen_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#android:color/transparent" />
<RelativeLayout
android:id="#+id/id_linear_layout_system_capacity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="105dip"
android:background="#drawable/home_storage_bg"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="40dip"
android:gravity="center_horizontal"
android:text="Dummy"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/id_linear_layout_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/home_seekbar_bg" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/home_bottom_bg"/ >
</LinearLayout>
you have put
android:layout_width="wrap_content" android:layout_height="wrap_content"
as wrap_content and there is no content inside your layout so it is not visible maybe
Fixed the problem by editing the code as below:-
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="17dip"
android:gravity="center_horizontal"
android:text="Dummy"
android:textStyle="bold" />
As I understand this invisible layout should be always visible in the bottom of the screen, then you should better use RelativeLayout insted of LinearLayout
Change this layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/GlobalBG"
android:orientation="vertical" >
TO <RelativeLayout> and set this android:layout_alignParentBottom="true" to your invisible layout
Edited:
this works for me
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/red" >
<RelativeLayout
android:id="#+id/id_linear_layout_system_capacity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="105dip"
android:background="#color/row_base_background_end"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="20dip"
android:gravity="center_horizontal"
android:text="Dummy"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/id_linear_layout_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#color/row_base_background_start" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/gray" >
</LinearLayout>
</RelativeLayout>
I have a layout like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e4e8ed"
android:gravity="top" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0px"
android:orientation="vertical"
android:padding="0px" >
<include
android:id="#+id/tabBar"
layout="#layout/tab" />
<Button
android:id="#+id/nist"
android:layout_width="match_parent"
android:layout_height="67dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="3dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
android:background="#drawable/ready"
android:textColor="#FFFFFF" />
<ListView
android:id="#+id/lastCases"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2.08"
android:longClickable="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="7dp"
android:layout_below="#id/app"
android:background="#drawable/dropshadow_custom" >
<TextView
android:id="#+id/error"
style="#style/AudioFileInfoOverlayText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="120dp"
android:gravity="center"
android:text="No Cases"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#D6D8D9"
android:textSize="40dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/app"
android:background="#000000"
android:gravity="bottom"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
I try to align the last LinearLayout on top of the layout which holds the ListView by using this tag: android:layout_alignTop="#+id/app" But it doesn't seem to work. How can accomplish this?
Many Thanks!
Without any content a Layout with layout_width="wrap_content" and layout_height="wrap_content" is not shown as its width and height have a value of 0! Even if you have set some background color nothing will appear! You either have to add some content to the layout or you have to define another layout dimension. The position of your layout with android:layout_alignTop="#+id/app" should be correct. Hope that helps.
You can set "layout_below" on the first layout targeting to the last layout.
The code is that, I put a button inside the top layout as an exemple (Obs: In your listview you should use 0dp in layout_weight cause you already use layout_weight ^^) :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e4e8ed"
android:gravity="top" >
<LinearLayout
android:id="#+id/app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0px"
android:orientation="vertical"
android:layout_below="#+id/top"
android:padding="0px" >
<Button
android:id="#+id/nist"
android:layout_width="match_parent"
android:layout_height="67dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="3dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
android:textColor="#FFFFFF" />
<ListView
android:id="#+id/lastCases"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.08"
android:longClickable="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="7dp"
android:layout_below="#+id/app" >
<TextView
android:id="#+id/error"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="120dp"
android:gravity="center"
android:text="No Cases"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#D6D8D9"
android:textSize="40dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/top"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#000000"
android:gravity="bottom"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Top"
/>
I am displaying a header and footer for a listview. Here I am displaying all the data dynamically. Now I want to keep a title to my footer...So I tried to keep another textview in my footer.xml file. But it is not accepting. How can I place a title for my footer data?
My Code:
<?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" >
<TextView
android:id="#+id/exptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#000000"
android:textSize="12dip" >
</TextView>
</LinearLayout>
Help me regarding this...Thanks in Advance
Try this
using two layout one is using the textview and other is using the listview
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="welcome"
android:textColor="#ffffff"
android:layout_gravity="center_horizontal" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="welcome"
android:textColor="#ffffff"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
Another XML:
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
Do I get you right? You want to place a TextView above and one below a ListView?
Than you have to do it like 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" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="TextView" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="TextView" />
The Important part ist the layout_weight attributes.
Try this
you can us two xml one is set the two textview and other xml used the listview
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="welcome"
android:textColor="#ffffff"
android:layout_gravity="center_horizontal" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="welcome"
android:textColor="#ffffff"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
Another XML:
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
In my app i have a custom dialog whose layout is like the following:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"
android:scrollbars = "vertical"
android:scrollbarAlwaysDrawVerticalTrack = "true"
android:padding="10dp" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="blablabla...."/>
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:src="#drawable/book1"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="blablablablablablablablabla..."/>
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:src="#drawable/book2"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
That is, i show a list of two horizontally placed widgets: a TextView showing some text and an, adjacent to the text, an ImageView widget showing an image.
What i would like to do is to show the ImageView widgets in such a way that they are aligned, that is, the image 1 start at the same column of image 2.
How can i do that?
Thx!
I'm not exactly sure what you are hoping for, but I would do the following:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="blablabla...." />
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
android:src="#drawable/book1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/image1"
android:text="blablablablablablablablabla..." />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_below="#+id/image1"
android:layout_alignParentRight="true"
android:src="#drawable/book2" />
</RelativeLayout>
</ScrollView>
I changed it to a relative layout and used some attributes such as android:layout_below
and android:layout_alignParentRight="true to get these changes. I hope this helps.