Android Dashboard Pattern - android

In Tim Bray's latest Android blog post he mentions the "dashboard" ui pattern (what is used for the Twitter app, Facebook app, etc. Is this layout as simple as a GridView with Buttons or is it something else?
Update:
The DashboardLayout was released by Roman Nurik last night. It is a derivative of the layout used in the Google IO 2010 app.

The best example you can use is from the Google I/O 2011 Android App. They implement all those design patterns in their app. You can find the code at the following link:
http://code.google.com/p/iosched/source/browse/android/res/layout/fragment_dashboard.xml?r=27a82ff10b436da5914a3961df245ff8f66b6252
The 2011 version uses a custom layout called 'DashboardLayout' in a fragment which gets shared in phone and tablet specific layouts. The logic in DashboardLayout is responsible for all the auto layout magic!

Code of DashboardLayout from IO 2010 app was rather buggy. But Roman Nurik has fixed it and now it's possible to use DashboardLayout easily in your app.
Howto:
Add this class into your project
In your layout, just drop couple of buttons inside DashboardLayout, similar like here.

I was able to achieve a similar dashboard using a relative layout. Its still a work in progress, so your mileage may vary.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lay_wrapper"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout android:id="#+id/lay_action"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000" >
<TextView android:id="#+id/label_header"
android:layout_width="wrap_content"
android:layout_height="50px"
android:text="#string/app_title"
android:textColor="#000000"
android:textSize="25sp"
android:paddingLeft="10px"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
<RelativeLayout android:id="#+id/lay_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/lay_action"
android:paddingTop="25px"
android:layout_centerInParent="true">
<Button android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button1"
android:padding="25dip"
android:drawableTop="#drawable/button1" />
<Button android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/button1"
android:text="#string/button2"
android:padding="25dip"
android:drawableTop="#drawable/button2" />
<Button android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/button1"
android:text="#string/button3"
android:padding="25dip"
android:drawableTop="#drawable/button3" />
<Button android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/button3"
android:layout_below="#id/button2"
android:text="#string/button4"
android:padding="25dip"
android:drawableTop="#drawable/button4" />
</RelativeLayout>
</RelativeLayout>

The Dashboard layout did not work for me, thus I suggest a layout based solution.
It's just a bunch of layouts within layouts.
The key is the relativity of weights between the spacing layouts and the content layouts.
You can very simply move icons and define other layouts for bigger or lighter dashboards.
Here is how it looks like:
And here is the xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/dashboard"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout style="#style/dashboard_space_vertical" />
<LinearLayout style="#style/dashboard_content_vertical" >
<FrameLayout style="#style/dashboard_space_horizontal" >
</FrameLayout>
<LinearLayout style="#style/dashboard_content_horizontal" >
<ImageView
style="#style/dashboard_imageview"
android:src="#android:drawable/sym_call_missed" />
<TextView
style="#style/dashboard_textview"
android:text="Text 1" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_horizontal" />
<LinearLayout style="#style/dashboard_content_horizontal" >
<ImageView
style="#style/dashboard_imageview"
android:src="#android:drawable/sym_call_missed" />
<TextView
style="#style/dashboard_textview"
android:text="Text 2" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_horizontal" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_vertical" />
<LinearLayout style="#style/dashboard_content_vertical" >
<FrameLayout style="#style/dashboard_space_horizontal" />
<LinearLayout style="#style/dashboard_content_horizontal" >
<ImageView
style="#style/dashboard_imageview"
android:src="#android:drawable/sym_call_missed" />
<TextView
style="#style/dashboard_textview"
android:text="Text 3" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_horizontal" />
<LinearLayout style="#style/dashboard_content_horizontal" >
<ImageView
style="#style/dashboard_imageview"
android:src="#android:drawable/sym_call_missed" />
<TextView
style="#style/dashboard_textview"
android:text="Text 4" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_horizontal" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_vertical" />
<LinearLayout style="#style/dashboard_content_vertical" >
<FrameLayout style="#style/dashboard_space_horizontal" />
<LinearLayout style="#style/dashboard_content_horizontal" >
<ImageView
style="#style/dashboard_imageview"
android:src="#android:drawable/sym_call_missed" />
<TextView
style="#style/dashboard_textview"
android:text="Text 5" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_horizontal" />
<LinearLayout style="#style/dashboard_content_horizontal" >
<ImageView
style="#style/dashboard_imageview"
android:src="#android:drawable/sym_call_missed" />
<TextView
style="#style/dashboard_textview"
android:text="Text 6" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_horizontal" />
</LinearLayout>
<FrameLayout style="#style/dashboard_space_vertical" />
</LinearLayout>
Here are the styles:
<resources>
<style name="dashboard_space_vertical">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">0px</item>
<item name="android:layout_weight">1</item>
</style>
<style name="dashboard_content_vertical">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">0px</item>
<item name="android:layout_weight">3</item>
<item name="android:layout_gravity">center</item>
</style>
<style name="dashboard_space_horizontal">
<item name="android:layout_width">0px</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">2</item>
<!-- <item name="android:background">#color/black</item> -->
</style>
<style name="dashboard_content_horizontal">
<item name="android:layout_width">0px</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">3</item>
<item name="android:orientation">vertical</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center</item>
</style>
<style name="dashboard_imageview">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:scaleType">fitCenter</item>
</style>
<style name="dashboard_textview">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center</item>
<item name="android:textSize">#dimen/dashboard_thumbnail_text_size</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#color/blue</item>
</style>
</resources>
Hope this helps someone. Enjoy.

It could be implemented with a TableLayout containing Image- and TextViews.

the best and the simplest way of creating Dashboard..
very nicely explained
How To Build A Dashboard User Interface In Android

romannurik posted recently a custom ViewGroup to do this. The code is here.

Related

Button layout with 4 separate "borders": Can't get text in center

I have created a button layout with 4 separate "border" views (left, right, top, bottom) and alpha-numeric text intended to be in the center. I using the 4 separate border views so I can selectively hide (or not) each side. When used in a grid layout, I intend to enable the borders on a per button basis to create gridlines between the buttons (think tic-tac-toe lines).
But I cannot seem to center the alpha-numeric text vertically inside the button. Any help would be appreciated.
Here is the relevant xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/dialPadButton"
android:id="#+id/pad_btn_2"
android:orientation="horizontal"
android:background="#android:color/darker_gray">
<!-- Left Border -->
<View style="#style/dialPadButtonVerticalBorderStyle"
android:id="#+id/left_border"
android:visibility="visible"
android:layout_alignParentLeft="true"
></View>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Top Border -->
<View style="#style/dialPadButtonHorizontalBorderStyle"
android:id="#+id/top_border"
android:visibility="visible"
android:layout_alignParentTop="true"
></View>
<!-- Alpha-numeric text -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical">
<TextView style="#style/dialPadButtonNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="#dimen/dial_number_text_size"
android:text="2"
android:layout_gravity="center" />
<TextView style="#style/dialPadButtonText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/dial_letter_text_size"
android:text="abc"
android:layout_gravity="center" />
</LinearLayout>
<!-- Bottom Border -->
<View style="#style/dialPadButtonHorizontalBorderStyle"
android:id="#+id/bottom_border"
android:visibility="visible"
android:layout_alignParentBottom="true"
></View>
</RelativeLayout>
<!-- Right Border -->
<View style="#style/dialPadButtonVerticalBorderStyle"
android:id="#+id/right_border"
android:visibility="visible"
android:layout_alignParentRight="true"
></View>
</RelativeLayout>
For additional reference, here are the style definitions:
<resources>
<style name="dialPadButton">
<item name="android:layout_width">100dp</item>
<item name="android:layout_height">100dp</item>
<item name="android:fontFamily">sans-serif</item>
</style>
<style name="dialPadButtonNumber">
<item name="android:textColor">#00FF00</item>
<item name="android:maxLines">1</item>
</style>
<style name="dialPadButtonText">
<item name="android:textColor">#00FF00</item>
<item name="android:layout_marginTop">-10dp</item>
<item name="android:maxLines">1</item>
</style>
<style name="dialPadButtonHorizontalBorderStyle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">2dp</item>
<item name="android:background">#EEEEEE</item>
</style>
<style name="dialPadButtonVerticalBorderStyle">
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">2dp</item>
<item name="android:background">#EEEEEE</item>
</style>
</resources>
you can do these
android:gravity="center"
or
android:layout_height="wrap_content"
on your LinearLayout
simply add
android:gravity="center"
to the linearlayout that holds the two textviews, the linear layout is defined match parent so you need the children to be gravity:center
like this :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<TextView style="#style/dialPadButtonNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="25sp"
android:text="2"
android:layout_gravity="center" />
<TextView style="#style/dialPadButtonText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:text="abc"
android:layout_gravity="center" />
</LinearLayout>

android : How to change background layout when focus and active

i have a problem when deploy my app, i want to change background layout color when focus and active, but when i run my aplication, there's nothing happen, this is my code :
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible" >
<LinearLayout
android:layout_width="600dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_marginLeft="30dp"
android:focusable="true"
android:clickable="true"
android:background="#drawable/layout_state"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_margin="5dp"
android:layout_gravity="center"
android:background="#drawable/border_corner_baris2"
android:orientation="horizontal">
<TextView
style="#style/Textview_for_label"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Nama Lengkap \n(Sesuai KTP / Identitas Lain)" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="#drawable/border_corner_baris3"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
android:layout_gravity="center"
android:background="#drawable/border_corner_4"
android:orientation="horizontal" >
<EditText
android:id="#+id/nama_pp"
style="#style/edittext_border_corner_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="20dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView style="#style/image_view" />
</LinearLayout>
and this is my layout_state :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_window_focused="false" android:state_enabled="true" android:drawable="#drawable/border_corner_baris1" />
<item android:state_window_focused="false" android:state_enabled="false" android:drawable="#drawable/border_corner_baris1" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="#drawable/border_corner_baris1_klik" />
<item android:state_enabled="true" android:state_activated="true" android:drawable="#drawable/border_corner_baris1_klik" />
<item android:state_enabled="true" android:drawable="#drawable/border_corner_baris1" />
<item android:state_focused="true" android:drawable="#drawable/border_corner_baris1_klik" />
<item android:drawable="#drawable/border_corner_baris1" />
</selector>
is this possible to make this condition happen on my apps? i hope somebody can help me to solve my problem, thank you very much.
It wont work unless there is click listener present on the view(Linear Layout in your case). Either add
android:clickable="true"
in your linear layout, or add the OnClickListener to the linear layout in your activity.

No Title Bar Android Theme

In my application I want to use the Theme.NoTitleBar, but on the other hand I also don't want to loose the internal Theme of the Android OS.. I searched on the net and Found the following answer.. I have modified my styles.xml and added the following line of code..
Inside values/styles.xml
<style name="Theme.Default" parent="#android:style/Theme"></style>
<style name="Theme.NoTitle" parent="#android:style/Theme.NoTitleBar"></style>
<style name="Theme.FullScreen" parent="#android:style/Theme.NoTitleBar.Fullscreen"></style>
Inside values-v11/styles.xml
<style name="Theme.Default" parent="#android:style/Theme.Holo"></style>
<style name="Theme.NoTitle" parent="#android:style/Theme.Holo.NoActionBar"></style>
<style name="Theme.FullScreen" parent="#android:style/Theme.Holo.NoActionBar.Fullscreen"></style>
Inside values-v14/styles.xml
<style name="Theme.Default" parent="#android:style/Theme.Holo.Light"></style>
<style name="Theme.NoTitle" parent="#android:style/Theme.Holo.Light.NoActionBar"></style>
<style name="Theme.FullScreen" parent="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen"></style>
In the application tag of the Manifest file I have added an attribute of:
android:theme="#style/Theme.NoTitle"
But when I try to run the code The images in my application gets Blurry.. But when I use the following tag:
android:theme="#android:style/Theme.NoTitleBar"
or
android:theme="#android:style/Theme.Light.NoTitleBar"
or
android:theme="#android:style/Theme.Black.NoTitleBar"
The images in the application comes in the correct form... But In this case I lose all the themes on the new Android OS..
Please help me how can I use NoTitleBar Theme without loosing the Images and the Native Theme..
Code for the layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/mainScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<include
android:id="#+id/main_top_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="#layout/top_bar_title" />
<RelativeLayout
android:id="#+id/container_bar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/main_top_bar"
android:layout_marginTop="-3dp"
android:background="#drawable/tab_nav_bar" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/container_bar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/container_bar1"
android:background="#drawable/location_nav_bar" >
<TableLayout
android:id="#+id/map_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:paddingBottom="5dp"
android:background="#drawable/map_bar_bg" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/MapPointer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:background="#drawable/map_pointer" />
<TextView
android:id="#+id/MapSeperator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="2dp"
android:text="|"
android:textColor="#979ca0"
android:textSize="20dp" />
<com.pnf.myevent.CustomTextView
android:id="#+id/DisplayLocation"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="5dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="#adabad"
android:textSize="12dp" />
<Button
android:id="#+id/RefreshBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:background="#drawable/refresh_button" />
</TableRow>
</TableLayout>
<TableLayout
android:id="#+id/calendar_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/MonthBtn"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/month_button" />
<Button
android:id="#+id/TodayBtn"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/today_button" />
<Button
android:id="#+id/WeekBtn"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/week_button" />
</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/container_bar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/container_bar2"
android:background="#drawable/cal_nav_bar" >
<Button
android:id="#+id/CalPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="5dp"
android:background="#drawable/left_arrow_button" />
<com.pnf.myevent.CustomTextView
android:id="#+id/CalTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:shadowColor="#ffffff"
android:shadowDx="0"
android:shadowDy="2"
android:shadowRadius="1"
android:text="Title"
android:textColor="#666666"
android:textSize="15dp" />
<Button
android:id="#+id/CalNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:layout_marginTop="5dp"
android:background="#drawable/right_arrow_button" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/container_bar4"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="#+id/container_bar3"
android:background="#c8c9cc" >
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:horizontalSpacing="2dp"
android:listSelector="#00000000"
android:numColumns="7"
android:stretchMode="columnWidth"
android:verticalSpacing="2dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/footer_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/container_bar4" >
<ListView
android:id="#+id/CalendarList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:listSelector="#00000000"
android:cacheColorHint="#00000000"
android:divider="#dedede"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false" />
</RelativeLayout>
if you want the original style of your Ui to remain and the title bar to be removed with no effect on that, you have to remove the title bar in your activity rather than the manifest. leave the original theme style that you had in the manifest and in each activity that you want no title bar use this.requestWindowFeature(Window.FEATURE_NO_TITLE); in the oncreate() method before setcontentview() like this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_signup);
...
}
To Hide the Action Bar add the below code in Values/Styles
<style name="CustomActivityThemeNoActionBar" parent="#android:style/Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
Then in your AndroidManifest.xml file add the below code in the required activity
<activity
android:name="com.newbelievers.android.NBMenu"
android:label="#string/title_activity_nbmenu"
android:theme="#style/CustomActivityThemeNoActionBar">
</activity>
In your manifest use:-
android:theme="#style/AppTheme" >
in styles.xml:-
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
Surprisingly this works as yo desire, Using the same parent of AppBaseTheme in AppTheme does not.
Why are you changing android os inbuilt theme.
As per your activity Require You have to implements this way
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
as per #arianoo says you have to used this feature.
I think this is better way to hide titlebar theme.
In your styles.xml, modify style "AppTheme" like
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
use android:theme="#android:style/Theme.NoTitleBar in manifest file's application tag to remove the title bar for whole application or put it in activity tag to remove the title bar from a single activity screen.
this.requestWindowFeature(getWindow().FEATURE_NO_TITLE);

how to make headers in android with text and buttons like in iOS

i want to create header in android with text and buttons like in iOS (Text in Cetner and Buttons on right and left side), i have tried but not useful at all,please guide me ... how can i make this one for my app
Try this. Make header.xml file and put below code in it and use it in any layout file using include .
<?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:orientation="horizontal"
android:background="#drawable/titlebar"
android:gravity="center">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_button"
android:background="#android:color/transparent"
android:layout_marginLeft="5.0dip"
android:id="#+id/imageButtonBack"
android:contentDescription="#string/ui_image_home_description"/>
<TextView
android:id="#+id/textViewTitleBar"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
style="#style/TitleBarText"
android:singleLine="false"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/home_button"
android:background="#android:color/transparent"
android:layout_marginRight="5.0dip"
android:id="#+id/imageButtonHome"
android:contentDescription="#string/ui_image_home_description"/>
</LinearLayout>
Note : Add the below style to style.xml in res/values folder.
<style name="TitleBarText">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textSize"> 17sp </item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:textColor">#color/white</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
This is an easier one. You can try this:
<RelativeLayout 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" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/header">
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Back" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Next" />
</RelativeLayout>
</RelativeLayout>

Text doesn't show up with android:textStyle="italic"

Below is the XML I am using and when I use the android:textStyle="italic" attribute, the text doesn't show up. Basically any TextView with the style SummarySubtitle will not show up.
<style name="SummarySubtitle" parent="#android:style/TextAppearance">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:gravity">right|center_vertical</item>
<item name="android:layout_weight">1</item>
<item name="android:paddingRight">6dp</item>
<item name="android:textSize">12dp</item>
<item name="android:textStyle">italic</item>
</style>
<?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="70dp"
android:orientation="vertical">
<LinearLayout android:id="#+id/summary_header"
android:layout_width="fill_parent" android:layout_height="30dp"
android:orientation="horizontal">
<TextView android:id="#+id/summary_title" android:text="Title"
style="#style/SummaryTitle"/>
<TextView android:id="#+id/summary_subtitle"
android:text="Subtitle " style="#style/SummarySubtitle"/>
</LinearLayout>
<LinearLayout android:id="#+id/summary_subheader"
android:layout_width="fill_parent" android:layout_height="20dp"
android:orientation="horizontal">
<TextView android:id="#+id/summary_min" android:text="#string/min"
style="#style/SummaryHeader"/>
<TextView android:id="#+id/summary_max" android:text="#string/max"
style="#style/SummaryHeader"/>
<TextView android:id="#+id/summary_avg" android:text="#string/avg"
style="#style/SummaryHeader"/>
</LinearLayout>
<LinearLayout android:id="#+id/summary_values"
android:layout_width="fill_parent" android:layout_height="20dp"
android:orientation="horizontal">
<TextView android:id="#+id/summary_value_min"
android:text="$0.00" style="#style/SummaryValue"/>
<TextView android:id="#+id/summary_value_max"
android:text="$0.00" style="#style/SummaryValue"/>
<TextView android:id="#+id/summary_value_avg"
android:text="$0.00" style="#style/SummaryValue"/>
</LinearLayout>
</LinearLayout>
All I found on the subject so far
http://groups.google.com/group/android-developers/browse_thread/thread/843376e298e95e14
Relevant quote: "Oh yeah, I have seen that too. But when you run your app, it renders
correctly."
It doesn't show up on the layout's graphical representation but works correctly when you build and run the app.
try using this code:
adInfoTV.setTypeface(Typeface.MONOSPACE,Typeface.ITALIC);

Categories

Resources