I have to add TabBar to each activities in my application. How do I do this?
You can use include tag or viewstub or even fragments
Here's how to use include to achieve what you want
Create layout file that describes your toolbar, e.g. toolbar.xml
In each XML layout file you want your toolbar to appear add include tag pointing to your toolbar.xml
Example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<include android:id="#+id/titleBar" layout="#layout/title_bar"
android:layout_width="fill_parent" android:layout_height="48dip" />
<!-- All the rest of your activity layout below -->
</RelativeLayout>
Related
I am trying to achieve like the image below how can i do in fragment android.libraries.places.widget i tried using relative layout but its not showing up inside the places widget can anyone suggest some good source to do it or is there any other layout which can be used to do it.
The Xml which i tried:
<?xml version="1.0" encoding="utf-8"?>
<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=".Maps.MapsAddress" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginTop="10dp"
android:id="#+id/autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.libraries.places.
widget.AutocompleteSup portFragment"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chetpet Chennai"
android:textSize="14sp"
android:id="#+id/toolbar_address">
</TextView>
</FrameLayout>
Root layout use : Relative
SearchBar layout can use searchview or floating searchview(external libraries)
Device Location can use relative layout so icon place at the start of parent and etc
Saved addresses you can use table layout.
Assign id to the different layout so that you can stack the layout inside of the root-relative layout
I implemented my own title in android using this following codes:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_load);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_title);
Unfortunately, the output is this:
I want to change the height of the title(left) similar to title(right). Modifying the height of the activity_title.xml wont work! Need help!
Why can't you use custom layout and integrate that?
R.layout.activity_title-> is your activity title
activity_load-> main screen..
in activity_load.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include
android:id="#+id/header"
layout="#layout/activity_title" />
<RelativeLayout
android:id="#+id/layouts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header" >
// use your load screen here..
</RelativeLayout>
</RelativeLayout>
In code:
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // no need of title.
as you created custom layout where you can apply.If you don't want for some screens just make as include header gone in programatically.
Can someone help me know how to place a Widget above a ActionBar in android.I have read some other similar queries on stackoverflow but it mentions its not possible.Following is the screen that i am trying to create.Can some one let me know how do i place the Blue layout portion above the actionbar?Or is there some other way of achieving this?
Following is my xml file
nearby.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"
android:background="#android:color/black"
>
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="100dp" >
</LinearLayout>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>
</LinearLayout>
However i am not getting the desired layout.The header layout is visible below the actionbar.
Desired Layout:
The blue bar that you see is the action bar, using a custom view. Check out setCustomView on how you can customize the action bar.
I have two layouts that contain a functionally identical panel. One requires a background with rounded bottom corners; one requires a background with all square corners. In all other respects, the panels are to be exactly the same.
Is it possible to change the background of the included layout without surrounding it in a <FrameLayout> or other wrapper?
You can create a wrapper layout just for the background and use the include for all the common widgets
first_layout.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:background="<FIRST_BACKGROUND>">
<include layout="#layout/main_layout"/>
</LinearLayout>
second_layout.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:background="<SECOND_BACKGROUND>">
<include layout="#layout/main_layout"/>
</LinearLayout>
Where main_layout contains all the components that you want to reuse
how can we use include tag in layout.xml. Also by using this what are the features we can implement.
<include> </include>
include is normally used to reuse the layouts if suppose you are doing app which consists of common header and footer layouts you can use like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#drawable/bg1" android:orientation="vertical">
<!—header layout->
<include android:id="#+id/container_header_lyt"
android:layout_height="wrap_content" android:layout_width="fill_parent"
layout="#layout/main" />
<!—contains other views in layout>
</LinearLayout>
in this case you are reusing layout main
But according to http://developer.android.com/guide/topics/manifest/manifest-intro.html no such tag is allowed