I put this code but the problem with the percentage gives me a warning, where shall I put them?
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3">
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="14">
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3">
</RelativeLayout>
try as below...
<?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"
android:weightSum="20" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="3"
android:background="#FF00FF" >
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="14"
android:background="#FFFF00" >
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="3"
android:background="#00FFFF" >
</RelativeLayout>
</LinearLayout>
Related
I would like to display on the same page a viewpager and a gridview like this one ![What I would like :)][1]
[1]: http://i.stack.imgur.com/Xzg7T.jpg but what i get is that ![what I got][1]
[1]: http://i.stack.imgur.com/iZxwU.png .
There are my layouts.The Gridview Item
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/frag_Acc_gridView_imageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#215487"
android:scaleType="centerCrop"
android:src="#drawable/ic_logo"/>
<TextView
android:id="#+id/frag_Acc_gridview_textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/frag_Acc_gridView_imageView"
android:layout_alignParentLeft="true"
android:background="#80000000"
android:gravity="center"
android:paddingLeft="15dp"
android:textColor="#ffffffff"
android:textSize="20sp"
android:text="#string/hello_world" />
</RelativeLayout>
GridView layout
<?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" >
<GridView
android:id="#+id/fragment_acc_gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>
</LinearLayout>
the main layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="10"
tools:context=".MainActivity">
<FrameLayout
android:id="#+id/fragment_acc_viewpager"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="6">
</FrameLayout>
<FrameLayout
android:id="#+id/fragment_accueil_gridview"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="4"
>
</FrameLayout>
</LinearLayout>
thanks
Take a look of this. You will get some help:-
http://www.rogcg.com/blog/2013/10/20/working-with-fragments-and-viewpager-on-android
i want to have like this design.header when listview and image bellow in this listview.i wrote xml code.also i used scrollview but my listview's height des not change when i adaptered my array.i can show only first item in listview.
in my option problem is xml file
this is a source xml file
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/ic_launcher"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ff0000" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/geocell" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/relativeLayout1"
android:orientation="vertical" >
<ListView
android:id="#+id/menu_listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout2"
android:orientation="horizontal" >
<ImageView
android:id="#+id/popapshow"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/geocell" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
Remove LinearLayout from the root and add ScrollView
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
Try this one
<ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
Right now it splits vertically...I want it to split horizontally. I've looked at everyone else that says theirs cuts horizontally and I can't tell the difference...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_weight="1" >
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1" >
</LinearLayout>
</LinearLayout>
Change your orientation to vertical
<?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:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_weight=".1" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight=".1" >
</LinearLayout>
</LinearLayout>
you should make the sub Views `fill_parent
<LinearLayout 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"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</LinearLayout>
</LinearLayout>
this will create 2 LLinearLayout objects side by side.
if you want to create the one ontop of the other, you should make the android:orientation="vertical" instead
This should work.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_weight="1" >
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1" >
</LinearLayout>
</LinearLayout>
I have a vertical linearlayout, it has inside two linearlayout with diferent elements, I would like to fix the first one to the top, and the second one centered, I'm trying it but doesn't work:
<?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"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_bg"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#3b5998"
>
elements
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="300dip"
android:layout_height="300dip"
android:background="#drawable/background_resto"
android:gravity="center"
>
elements
</LinearLayout>
</LinearLayout
Why is it not working? Thank you in advance
I'd advice to choose a RelativeLayout for that purpose.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/holo_blue_bright"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentTop="true"
android:background="#fff" >
</LinearLayout>
<LinearLayout
android:layout_width="300dip"
android:layout_height="300dip"
android:layout_centerInParent="true"
android:background="#android:color/holo_green_light"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
This will help you to set the exact "relative" position in relation to other views.
Best wishes,
Tim
should use RelativeLayout instead of LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_bg"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#3b5998"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
>
elements
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="300dip"
android:layout_height="300dip"
android:background="#drawable/background_resto"
android:layout_centerInParent="true"
>
elements
</LinearLayout>
</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="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_bg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentTop="true"
android:background="#ff0000" >
</LinearLayout>
<LinearLayout
android:layout_width="300dip"
android:layout_height="300dip"
android:layout_centerInParent="true"
android:background="#ff0000"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
</LinearLayout>
i am doing a application with this main.xml layout :
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="#+id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="#android:id/tabs"></TabWidget>
<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="#android:id/tabcontent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#013364"
android:id="#+id/tab1">
<ListView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="#+id/listView2"
android:background="#efefef" android:cacheColorHint="#00000000"></ListView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#013364"
android:id="#+id/tab2">
<ListView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="#+id/listView1"
android:background="#efefef" android:cacheColorHint="#00000000"></ListView>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="#+id/tab3">
<WebView android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="#+id/webview" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#013364"
android:id="#+id/tab4">
<ListView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="#+id/listView3"
android:background="#efefef" android:cacheColorHint="#00000000"></ListView>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
So you can see that i have 4 tabs zones, and i want to put my ads in yellow zone of my image in all tabs :
how could i do such thing.
Thanks in advance.
This is what i wanted :
<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#013364"
android:id="#+id/tab1">
<ListView android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#efefef" android:cacheColorHint="#00000000" android:layout_marginBottom="50dip"/>
//CODE OF ADS </FrameLayout>