<?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="#808285"
android:orientation="vertical">
<LinearLayout android:id="#+id/homeHeaderLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="34dp"
android:background="#drawable/header_bg">
<ImageView android:id="#+id/searchImageView"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:background="#drawable/header_bg_states"
android:layout_gravity="center|center_vertical"
android:layout_weight="25"
android:scaleType="center"
android:src="#drawable/ic_search"/>
<View android:layout_height="match_parent"
android:layout_width="1.2dp"
android:background="#drawable/header_divider"/>
<ImageView android:id="#+id/headerLogo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/header_bg_states"
android:layout_gravity="center|center_vertical"
android:layout_weight="50"
android:scaleType="center"
android:src="#drawable/madisons_logo"/>
<View android:layout_height="match_parent"
android:layout_width="1.2dp"
android:background="#drawable/header_divider"/>
<ImageView android:id="#+id/shoppingCartImageView"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:background="#drawable/header_bg_states"
android:layout_gravity="center|center_vertical"
android:layout_weight="25"
android:scaleType="center"
android:src="#drawable/ic_cart"/>
</LinearLayout>
<TabHost android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<TabWidget android:id="#android:id/tabs"
android:layout_height="35dp"
android:layout_width="match_parent"
android:background="#drawable/tabs_bg"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="1dp"
android:orientation="vertical"
android:tabStripEnabled="true"
style="#style/TabText"/>
<View android:layout_height="0.5dp"
android:layout_width="match_parent"
android:background="#FFFFFF"/>
<FrameLayout android:id="#android:id/tabcontent"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#FFFFFF"/>
</LinearLayout>
</TabHost>
Tabs are not coming in my device... but in emulator they are showing & working.
my requirement is is work in Google API2.2 version level_8
please anyone can tell me the solution for this
Related
I made the Layout as follows.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_below="#+id/layout_progress"
android:layout_alignParentStart="true"
android:layout_weight="1">
</android.support.v7.widget.Toolbar>
<ScrollView
android:id="#+id/scroll_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/linearLayout12"
android:layout_alignParentBottom="true"
android:layout_marginTop="?attr/actionBarSize"
android:layout_weight="0"
android:fillViewport="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/message_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</android.support.v7.widget.RecyclerView>
</ScrollView>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_above="#+id/linearLayout8"
android:layout_alignParentLeft="true">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout8"
android:layout_above="#+id/layout_inputfield"
android:layout_alignParentLeft="true">
</LinearLayout>
<LinearLayout
android:id="#+id/layout_inputfield"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="#drawable/test" />
<ImageView
android:id="#+id/imageView18"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="#drawable/test2" />
<ImageView
android:id="#+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="#drawable/test3" />
</LinearLayout>
<EditText
android:id="#+id/edit_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:ems="10"
android:inputType="textMultiLine"
android:textColor="#android:color/black">
<requestFocus />
</EditText>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
The problem is that the UI is cut when the keyboard is uploaded.
So I solved it with the [adjustpan] option.
This is the same result as I intended.
But I can't even see the "toolbar."
I always want to show "toolbar" at the top.
1
2
I'll attach the image to the current situation more easily.
If you need any information, please let me know.
I tried all the answers similar to that question on this website but still couldnt fix it. taphost is below the action bar and i wanna make it above the action bar. I have a custom action bar.
<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"
tools:context="com.mediamer.metwally.saidkotb.activities.makalatActivity"
android:layoutDirection="rtl"
android:orientation="vertical"
>
<TabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
This is my custom action bar
<?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:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3"
>
<ImageView
android:layout_width="0dp"
android:layout_height="22dp"
android:src="#drawable/homebutton"
android:layout_gravity="center"
android:layout_weight="0.40"
android:id="#+id/homeButton"
/>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.60"
/>
<com.mediamer.metwally.saidkotb.helpers.CustomTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#color/TextColor"
android:id="#+id/mytext"
android:textSize="25sp"
android:layout_weight="1"
/>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.60"
/>
<android.support.v7.widget.SearchView
android:id="#+id/svZelal"
android:layout_width="0dp"
android:searchIcon="#android:drawable/ic_menu_search"
android:layout_height="match_parent"
android:layout_weight="0.40"
/>
</LinearLayout>
</LinearLayout>
I am new to Android and was working on designing an app. I had worked for my phone device hoping it would work on tablet (Nexus 7) too. I used view pager and frames to make tabs. But it works fine on phone and not on tablet.
The upper one is for phone and the lower one is for tablet. Please suggest what wrong I did.
Here's my activity_main.xml file:-
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivityNew"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_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:background="#color/white"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"/>
<com.meroanswer.SlidingTabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center"
android:textAlignment="textStart"
android:elevation="2dp"
android:background="#color/primary"/>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</LinearLayout>
<!--<android.support.v7.widget.RecyclerView
android:id="#+id/RecyclerView"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#ffffff"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>-->
<ListView
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/windowBackgroundColor"/>
</android.support.v4.widget.DrawerLayout>
Here's tab_subject.xml file:-
<?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">
<GridView
android:id="#+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/toolbar"
android:padding="4dp"
android:clipToPadding="false"
android:columnWidth="#dimen/item_width"
android:numColumns="auto_fit"
android:horizontalSpacing="4dp"
android:verticalSpacing="4dp"
android:stretchMode="columnWidth"/>
</RelativeLayout>
Here's my grid_items.xml file:-
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_height="2dp"
android:layout_width="fill_parent"
android:background="#88cdcdcd" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:baselineAligned="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3">
<ImageView
android:id="#+id/image"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="centerCrop"
android:layout_marginLeft="10dp"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="0.4"
android:layout_height="match_parent"
android:layout_gravity="left"
android:gravity="center">
<TextView
android:id="#+id/subject_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Physics"
android:textSize="20dp"
android:textColor="#color/black_translucent"/>
<TextView
android:id="#+id/chapters_completed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="50 chapters"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_weight="0.3"
android:layout_height="80dp"
android:layout_gravity="right"
android:gravity="center">
<TextView
android:id="#+id/progress_gained"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
android:textColor="#color/progressColor"
android:padding="#dimen/spacing_large"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
The activity_main.xml file is the main activity layout, tab_subjects.xml is the layout file for the Model Exam tab currently. And then the grid_items.xml file is later added on the gridview.
Found a solution. It was because I had added fixed width on gridview as suggested by AndroidWeblineindia.
I want to create this layout where there are three equal ImageViews in a linear layout with layout_weight = 1.0 each. I just want to put two circular images on the inner edges aligned center vertically in android. Maybe I cant achieve this in XML or maybe yes. Please help me achieving this properly.
Try this way,hope this will help you to solve your problem.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/white">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/black">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/white">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="right">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="left">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<?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" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#123456"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#654321"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="30dp"
android:src="#android:drawable/alert_dark_frame" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:src="#android:drawable/alert_light_frame" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</FrameLayout>
</LinearLayout>
i am developing application for tablet.i have xml file i put this files layout folder and layout-land folder in this xml i used framelayout including image view but when i run application image is not displayed.Could you tell me why image is not displayed.
i attached full source code of xml file
<?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="#drawable/frontbackground"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#color/header"
android:orientation="horizontal"
android:weightSum="3" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/navigation" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="2dp"
android:text="Kesari"
android:textColor="#color/textcolor"
android:textSize="14sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_weight="2"
android:text="Choose from the exciting holiday packages across 7 continents from world class travel company"
android:textColor="#color/textcolor"
android:textSize="14sp" />
</LinearLayout>
<TabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TabWidget>
</HorizontalScrollView>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:orientation="vertical" >
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/linearLayout1" >
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab5"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab6"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab7"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
<FrameLayout
android:id="#+id/framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/ImageView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/malaysia1"></ImageView>
</FrameLayout>
</LinearLayout>
This must be because you have given height to tabHost as match_parent.Replace it with wrap_content and your imageView also use wrap_content for height.