android Separator after last item of ListView - android

I have two listviews and two different adapters for them. one shows the bottom divider but the other list does not show divider after the last item.
The one which shows divider after last item, only has listview in the layout. other one which does not shows divider has other views along with the listview.
both listviews have the same style which is below.
<style name="st_comman_data_list">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:background">#color/app_background_color</item>
<item name="android:cacheColorHint">#color/app_background_color</item>
<item name="android:drawSelectorOnTop">true</item>
<item name="android:fadeScrollbars">true</item>
<item name="android:fadingEdge">none</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:listSelector">#drawable/list_states_color</item>
<item name="android:scrollbarFadeDuration">1000</item>
<item name="android:fastScrollEnabled">true</item>
</style>
Edit
layout xml for correct divider
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/app_background_color_light"
android:orientation="vertical" >
<ListView
android:id="#+id/gift_home_ui_home_list"
style="#style/st_comman_data_list"
android:layout_height="match_parent" />
xml which don't shows divider
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/app_background_color"
android:cacheColorHint="#color/app_background_color"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_header"
android:gravity="center"
android:visibility="gone" >
<Button
android:id="#+id/tab_video_main_btn_all"
style="#style/st_btn_top_header_gry"
android:layout_marginRight="2dp"
android:text="#string/st_tab_main_btn_all" />
<Button
android:id="#+id/tab_video_main_btn_my_videos"
style="#style/st_btn_top_header_gry"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:text="#string/st_tab_video_main_btn_my_videos"
android:visibility="visible" />
<Button
android:id="#+id/tab_video_main_btn_saved"
style="#style/st_btn_top_header_gry"
android:layout_marginLeft="2dp"
android:text="#string/st_tab_main_btn_saved" />
</LinearLayout>
<View style="#style/st_single_black_line" />
<TableLayout
android:id="#+id/video_search_holder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/background_header_small"
android:focusableInTouchMode="false"
android:gravity="left"
android:stretchColumns="0"
android:visibility="gone" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_margin="#dimen/margin_basic_very_large"
android:background="#drawable/audio_search_bg"
android:gravity="left|center_vertical"
android:paddingLeft="#dimen/padding_basic_2dp"
android:paddingRight="#dimen/padding_basic_2dp" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" >
<ImageButton
android:id="#+id/video_btn_search_clear"
style="#style/st_search_ui_ic_search"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:src="#drawable/ic_clear_search"
android:visibility="gone" />
<ImageButton
android:id="#+id/video_btn_search"
style="#style/st_search_ui_ic_search"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_search" />
<EditText
android:id="#+id/video_search_edit_text"
style="#style/st_search_ui_search_bar"
android:layout_toLeftOf="#id/video_btn_search_clear"
android:layout_toRightOf="#id/video_btn_search"
android:focusable="false"
android:focusableInTouchMode="false"
android:hint="#string/hint_search_by_video_title_or_description"
android:imeOptions="actionDone"
android:singleLine="true"
android:windowSoftInputMode="stateVisible|adjustResize" />
</RelativeLayout>
</TableRow>
</TableLayout>
<ListView
android:id="#+id/no_more_text_list"
style="#style/st_no_more_text_list"
android:visibility="gone" />
<ListView
android:id="#+id/video_chanel_list"
style="#style/st_comman_data_list" />
<View
android:id="#+id/invisible"
android:layout_width="match_parent"
android:layout_height="1dp" />
Solutions which i have tried:
set height as "match_parent"
add a view under the list view and make it invisible
set footer divider as enabled (which is true by default)
Someone have any ides why it is behaving differently?

Related

Custom dialog becomes the size of the first control in android

I have the following layout for my custom log in dialog
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/padding_large">
<ImageButton android:src="#drawable/ic_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/dialog.login.settings"
android:padding="#dimen/margin_medium" />
<TextView android:text="#string/dialog.login.text.user_name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText android:id="#+id/dialog.login.user_name"
android:layout_width="match_parent"
android:gravity="center"
android:ems="20"
android:layout_height="wrap_content"
android:inputType="text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView android:text="#string/dialog.login.text.password"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText android:id="#+id/dialog.login.password"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox android:id="#+id/dialog.login.show_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/dialog.login.check.show_password"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_margin="#dimen/margin_medium"
android:checked="false" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="#+id/dialog.login.cancel"
android:drawableStart="#drawable/ic_exit_black"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_medium"
android:text="#string/dialog.login.button.cancel" />
<Button android:id="#+id/dialog.login.connect"
android:text="#string/dialog.login.button.connect"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_marginStart="#dimen/margin_medium"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
when I create the dialog and setcontentview the width of the dialog becomes equal to that of the image button on the first row
if I remove that , it becomes the size of the EditText (dialog.login.user_name) whose ems is 20
when I make the dialog's constructor call the base dialog constructor with a theme of R.style.Theme.Material.Dialog it does get the correct (about 3/4 of the screen) but the problem is that it ignores my primary and accent colours (which is normal)
Is there a way to have the dialog have the Theme.Material.Dialog size but still keep my own primary/accent colours?
thanks in advance for any help you can provide
After a lot of searching it seems that the solution is to actually replace the dialogTheme attribute of my main theme, so the solution was:
<style name="app.theme"
parent="android:Theme.Material.Light.NoActionBar.Fullscreen">
<item name="android:dialogTheme">#style/app.dialog</item>
......
</style>
<style name="app.dialog"
parent="android:Theme.Material.Light.Dialog">
<item name="android:colorPrimary">#color/primary</item>
<item name="android:colorPrimaryDark">#color/primary.dark</item>
<item name="android:colorAccent">#color/accent</item>
</style>

Android Listview Item : How to set custom height of the item?

I have the following list item layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/AppTheme.ListViewItemStyle_1">
<View android:id="#+id/data_view_stripe"
style="#style/AppTheme.RedStripe"/>
<ImageView android:id="#+id/data_iv_main"
style="#style/AppTheme.ImageBig"
android:src="#drawable/web_icon_weight"
android:contentDescription="Item icon"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="4"
android:padding="4dp"
android:layout_gravity="center">
<TextView android:id="#+id/data_tv_title"
style="#style/AppTheme.ListItemDefaultHeading"
android:text="BP - diastolic"/>
<TextView android:id="#+id/data_tv_value"
style="#style/AppTheme.WrapContent.Value"
android:text="87 mmHg"/>
<TextView android:id="#+id/data_tv_occurence_desc"
style="#style/AppTheme.WrapContent.Calendar"
android:text="Daily at 8:00"/>
<TextView android:id="#+id/data_tv_overdue"
style="#style/AppTheme.WrapContent.Schedule"
android:text="Overdue (Today at 8:00)"/>
<TextView android:id="#+id/data_tv_test_time"
style="#style/AppTheme.WrapContent.Schedule"
android:text="Overdue (Today at 8:00)"/>
</LinearLayout>
<ImageButton android:id="#+id/data_btn_favourite"
style="#style/AppTheme.RatingBasic"
android:paddingLeft="15dp"
android:paddingRight="0dp"
android:contentDescription="Favourite button"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center">
<ImageView android:id="#+id/data_iv_trend"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="#drawable/ic_arrow_down"
android:contentDescription="Progress indicator"/>
<ImageButton android:id="#+id/data_btn_info"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/background_white"
style="#style/AppTheme.Info"
android:contentDescription="Information button"/>
</LinearLayout>
</LinearLayout>
With the following styles:
<!-- Base ListVIew Item -->
<style name="AppTheme.ListViewItemBase" >
<item name="android:background">#color/background_white</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
<item name="android:paddingRight">10dp</item>
<item name="android:divider">#android:color/holo_red_dark</item>
<item name="android:dividerHeight">10dp</item>
<item name="android:orientation">horizontal</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_gravity">center</item>
</style>
<!-- ListVIew Item style 01-->
<style name="AppTheme.ListViewItemStyle_1" parent="AppTheme.ListViewItemBase">
<item name="android:layout_height">50dp</item>
<item name="android:descendantFocusability">blocksDescendants</item>
</style>
I tried to set the custom height of the item to 50dp using the:
android:layout_height
Height was changed in Android Studio layout preview, but if i deployed app into real device height of the item stayed unchanged.
How can i set custom height for list item using styles please?
Many thanks for any advice.
EDIT:
By Your suggestion i tried following example which is not working for me (item height is still same).
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="20dp"
>
<View android:id="#+id/data_view_stripe"
style="#style/AppTheme.RedStripe"/>
<ImageView android:id="#+id/data_iv_main"
style="#style/AppTheme.ImageBig"
android:src="#drawable/web_icon_weight"
android:contentDescription="Item icon"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="4"
android:padding="4dp"
android:layout_gravity="center">
<TextView android:id="#+id/data_tv_title"
style="#style/AppTheme.ListItemDefaultHeading"
android:text="BP - diastolic"/>
<TextView android:id="#+id/data_tv_value"
style="#style/AppTheme.WrapContent.Value"
android:text="87 mmHg"/>
<TextView android:id="#+id/data_tv_occurence_desc"
style="#style/AppTheme.WrapContent.Calendar"
android:text="Daily at 8:00"/>
<TextView android:id="#+id/data_tv_overdue"
style="#style/AppTheme.WrapContent.Schedule"
android:text="Overdue (Today at 8:00)"/>
<TextView android:id="#+id/data_tv_test_time"
style="#style/AppTheme.WrapContent.Schedule"
android:text="Overdue (Today at 8:00)"/>
</LinearLayout>
<ImageButton android:id="#+id/data_btn_favourite"
style="#style/AppTheme.RatingBasic"
android:paddingLeft="15dp"
android:paddingRight="0dp"
android:contentDescription="Favourite button"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_gravity="center">
<ImageView android:id="#+id/data_iv_trend"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="#drawable/ic_arrow_down"
android:contentDescription="Progress indicator"/>
<ImageButton android:id="#+id/data_btn_info"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#color/background_white"
style="#style/AppTheme.Info"
android:contentDescription="Information button"/>
</LinearLayout>
</LinearLayout>
Remove
style="#style/AppTheme.ListViewItemStyle_1"
Where is android:orientation
Then.You can try this way ,
<?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="50dp"
android:orientation="horizontal">
Note:
set android:orientation="" as horizontal or vertical as per your requirement

Android: center background of radio button

I need to use custom radio buttons with background image, and space them evenly horizontally, I can achieve the spacing but cannot position the background image in the center of each button. My layout is as below.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="58dp">
<RadioGroup
android:id="#+id/group_bottom_bar"
android:layout_width="match_parent"
android:layout_height="52dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/v4_btn_trip"
style="#style/BottomTabBarButtonStyle"
android:button="#drawable/v4_tabbar_radio_trip" />
<RadioButton
android:id="#+id/v4_btn_agenda"
style="#style/BottomTabBarButtonStyle"
android:button="#drawable/v4_tabbar_radio_agenda" />
<RadioButton
android:id="#+id/v4_btn_favorite"
style="#style/BottomTabBarButtonStyle"
android:button="#drawable/v4_tabbar_radio_favorite" />
<RadioButton
android:id="#+id/v4_btn_settings"
style="#style/BottomTabBarButtonStyle"
android:button="#drawable/v4_tabbar_radio_settings" />
</RadioGroup>
</RelativeLayout>
The style is per below:
<style name="BottomTabBarButtonStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:layout_weight">1</item>
I already set the gravity to center_horizontal.
I tried to replace android:button with android:background but that just stretched the image.
One of the selector files (v4_tabbar_radio_trip)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/ic_bottom_tab_trip_active" android:state_checked="true" android:state_pressed="true" />
<item android:drawable="#drawable/ic_bottom_tab_trip_active" android:state_pressed="true" />
<item android:drawable="#drawable/ic_bottom_tab_trip_active" android:state_checked="true" />
<item android:drawable="#drawable/ic_bottom_tab_trip" />
</selector>
This is its current state.
Update: The expected output is that the background image (the two dots) is in the middle of the greyed area (which is the radio button), not aligned to the left. Similarly for other icons
You can try this layout xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="58dp" >
<RadioGroup
android:id="#+id/group_bottom_bar"
android:layout_width="match_parent"
android:layout_height="52dp"
android:orientation="horizontal" >
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RadioButton
android:id="#+id/v4_btn_trip"
android:layout_gravity="center"
android:button="#drawable/v4_tabbar_radio_trip" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RadioButton
android:id="#+id/v4_btn_agenda"
android:layout_gravity="center"
android:button="#drawable/v4_tabbar_radio_agenda" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RadioButton
android:id="#+id/v4_btn_favorite"
android:layout_gravity="center"
android:button="#drawable/v4_tabbar_radio_favorite" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RadioButton
android:id="#+id/v4_btn_settings"
android:layout_gravity="center"
android:button="#drawable/v4_tabbar_radio_settings" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</RadioGroup>
</LinearLayout>
I know this is not good way of handling the things but it can do a trick for you and it is feasible for all screens.
Try it. Hope this helps you.
try to write
style="#style/BottomTabBarButtonStyle"
after the
android:button="#drawable/v4_tabbar_radio_settings"
in layout xml file.
Try out this!!
<LinearLayout
android:id="#+id/ll_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:weightSum="2" >
<RadioGroup
android:id="#+id/radioGrouprecharge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radioPreapaid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:button="#android:drawable/btn_radio" />
<RadioButton
android:id="#+id/radIoPostpaid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center_horizontal" />
</RadioGroup>
</LinearLayout>
You are centering your button, but the drawable is always left-aligned.
The solution appears to be create a new radio group. Here is an example.

Android how to use auto-layout to move other views when a view is hidden?

I wanted to make resizable views when one of them is hidden. The question is already asked for iOS in the following link. I wanna make it for android. Any helps are appreciated. I wanted to add free space to three TextViev: position, stat_name, price after setting visibility hidden to count and discount
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingTop="30dp"
android:weightSum="100" >
<TextView
style="#style/list_titles_style"
android:layout_weight="10"
android:text="#string/position" />
<TextView
style="#style/list_titles_style"
android:layout_weight="35"
android:paddingLeft="15dp"
android:text="#string/stat_name" />
<TextView
style="#style/list_titles_style"
android:layout_weight="20"
android:text="#string/price" />
<TextView
android:id="#+id/count_label"
style="#style/list_titles_style"
android:layout_weight="10"
android:visibility="invisible"
android:text="#string/count" />
<TextView
android:id="#+id/discount_label"
style="#style/list_titles_style"
android:visibility="invisible"
android:layout_weight="25"
android:text="#string/discount" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="1dp"
android:background="#drawable/border_layout"
android:orientation="horizontal" >
<ListView
android:id="#+id/stats_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_marginBottom="5dp"
android:divider="#drawable/list_divider"
android:dividerHeight="2dp"
android:paddingBottom="0dp"
android:paddingLeft="10dp"
android:paddingTop="0dp" />
</LinearLayout>
And my style here it is:
<style name="list_titles_style">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:textColor">#color/Blue</item>
<item name="android:gravity">center</item>
<item name="android:textSize">18sp</item>
</style>
I have gone through the provided link...To remove the left side view just set the android:visibility="gone" for the view in your xml layout file....if you want remove programmatically try view.setVisibility(View.GONE);....
You can achieve this using LinearLayout with match_parent parameter depending on what orientation you desire. So you might set weights for each child view and also put an stub view in order to stretch out the size.
Note that if you hide your views with INVISIBLE flag they will hold the space whereas with GONE it's like the view never been there.
Hope that helps.

Create Dialog-link popup for text message link HandcentSMS

I'm in the middle of modifying a test message application and one of the features that I'd like to add to it would be that when a text message is received, a dialog box of some sort would pop up with the text message stuff and the ability to quickly reply to it, all without having to go into the actual application. Taking HandcentSMS as an example, here is what I'm talking about:
Any ideas how to go about doing this, or could anyone point me in a good direction to get started on this?
You can make an activity, and style it with custom style which should inherit Theme.Dialog
Example style:
<style name="Theme.MyDialog" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">#android:drawable/alert_light_frame</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:overScrollMode">never</item>
<item name="android:windowNoTitle">true</item>
</style>
The most important thing is to prepare xml layout of the activity properly.
I suggest to WRAP_CONTENT for everything vertically, and FILL_PARENT horizontally.
Sample layout xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="280dp"
android:orientation="vertical">
<LinearLayout
android:id="#+id/frg_alert_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/topbar_logo"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:padding="10dp"
android:text="Title"/>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#android:drawable/divider_horizontal_bright"/>
</LinearLayout>
<FrameLayout
android:id="#+id/customPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone">
<FrameLayout
android:id="#+id/custom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
<ScrollView
android:id="#+id/messagePanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:padding="10dp">
<TextView
android:id="#android:id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Some text"/>
</ScrollView>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#android:drawable/divider_horizontal_bright"/>
<LinearLayout
android:id="#+id/frg_alert_three_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:visibility="gone"
android:weightSum="3">
<Button
android:id="#+id/button_positive"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:maxLines="2"
android:minLines="2"
android:text="Button"/>
<Button
android:id="#+id/button_neutral"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:maxLines="2"
android:text="Button"/>
<Button
android:id="#+id/button_negative"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:maxLines="2"
android:text="Button"/>
</LinearLayout>
<LinearLayout
android:id="#+id/frg_alert_two_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="#dimen/screenPadding"
android:weightSum="2">
<Button
android:id="#+id/button_positive"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="2"
android:minLines="2"
android:text="Button"/>
<Button
android:id="#+id/button_negative"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:maxLines="2"
android:minLines="2"
android:text="Button"/>
</LinearLayout>
</LinearLayout>
for Create this UI just Create an Activity with background transparent as:
Step 1: add res\values\style.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Smspopuptheme" parent="android:style/Theme.Translucent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">#android:color/transparent</item>
</style>
</resources>
Step 2: add theme to in AndroidManifest.xml for activity which u want to show with message as:
<activity
android:label="#string/app_name"
android:theme="#style/Theme.D1NoTitleDim"
android:name=".SmspopuptestActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Step 3: In SmspopuptestActivity.java set FEATURE_NO_TITLE before setContentView as:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
//this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
Step 4: Your Activity layout look like res/layout/main.xml :
<?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:background="#55000000"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/frg_alert_buttons"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#android:color/darker_gray"
android:gravity="center"
android:padding="5dp"
android:layout_centerInParent="true"
android:weightSum="3">
</LinearLayout>
</LinearLayout>
add your layout elements in frg_alert_buttons likes Buttons, Textviews,Imageview and EditViews as per your need.
Start SmspopuptestActivity.java Activity when you receive new SMS.
Some helpful resources:
android-listen-for-incoming-sms-messages
SOME SOUCE CODE FOR SMSPOPUP IN ANDROID:
droid-notify
android-smspopup
showsms
smspopup-for-android

Categories

Resources