android-ui

How do I change the textColorPrimary in a theme?

狂风中的少年 提交于 2019-12-21 12:07:13
问题 I'm changing the theme of an activity in onCreate using setTheme (I'm doing that even before calling super.onCreate(), as this is supposed to be more reliable). It does work in the sense that it changes the background and foreground colors. However, my layout has a few elements that use styles like textAppearanceLarge. Now Android's textAppearanceLarge internally uses the textPrimaryColor - which is still unchanged by my theme. I tried to override the primary text color in my theme, but that

What is the alternative to getActionView() before API level11 in android?

依然范特西╮ 提交于 2019-12-20 10:18:25
问题 getActionView() for action bar was introduced in API 11 , If I want backward compatibility what is the alternative for getActionView() ? e.g. public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.action_bar_menu, menu); final MenuItem item = menu.findItem(R.id.menuitem); item.getActionView() //Works from API level 11 return true; } 回答1: For backwards compatibility you can use either ActionBarCompat or ActionBarScherlock . In both cases you can use the method

How to finish parent activity from child activity

戏子无情 提交于 2019-12-20 09:49:36
问题 I am new to Android development. I have created a main Activity (->A), which has 4 buttons. One of the 4 buttons is the EXIT-button. I start another activity (->B), on click of the EXIT-button. This opens 'B'Activity via an intent from 'A'Activity. Activity 'B' contains - Do you want to exit? Yes-Button & No-Button. If I give finish(), onclick of the button - it exits the 'B'Activity. I want to finish 'B' & 'A'. I have even tried A.finish() -> this doesn't get recognized and results in syntax

Android - ScrollView like foursquare with maps + list

五迷三道 提交于 2019-12-20 08:55:08
问题 This is the Android equivalent of this iOS question. Trying to create a view that contains a MapView at about 20% of the screen (under an ActionBar...) and the rest of the screen is a ScrollView that when scrolling down, overlaps on top of the MapView and hides it. In short like FourSquare's Android app. Any ideas? 回答1: I've made an implementation based on AndroidSlidingUpPanel (many thanks to this project). Details http://android.amberfog.com/?p=915 Source code with example: https://github

Thumbnail does not fill_parent as expected

萝らか妹 提交于 2019-12-20 05:47:40
问题 I'm attempting to get my thumbnail (userVideoThumbImageView) to extend to the edge of the screen but it does not seem to do so. I have the width set to fill_parent so I'm not sure why it isn't doing so: Screenshot: http://www.flickr.com/photos/110503723@N07/11207214295 list_item_user_video.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:gravity=

Get delay on UI thread

半世苍凉 提交于 2019-12-19 21:47:30
问题 I'm setting color of a listview item using the following code parent.getChildAt(itemPosition).setBackgroundColor(Color.parseColor("#FF9494")); This piece of code I'm writing in OnItemClickListener . After setting the color I want to keep this color for a time of 4 Seconds and then restore the color of the item to its previous(say White). I tried putting a sleep on the UI thread, but I know that it is not a correct approach. Can anyone suggest me how to achieve this? 回答1: parent.getChildAt

How to gradient fill a button's background?

余生颓废 提交于 2019-12-19 10:05:08
问题 I have to create a colored button with gradient fill(starting from the middle of the button along Y axis). If I set the background property of the button to the color I want, I lose the rounded look and feel of a button and also the gradient fill(It looks like a TextView with a background). Also, I want this color to change when the user depresses the button. Can i specify this via selector XMLs(Color State Lists)? Any tutorials or links that can help me here is appreciated. Thanks. 回答1: How

Android translucent background with shadow

血红的双手。 提交于 2019-12-19 04:47:27
问题 I'm trying to create a background drawable resource in XML that is translucent, but with a solid shadow. This is what I have so far: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle" > <padding android:top="-2dp" android:left="-2dp" android:right="2dp" android:bottom="2dp" /> <gradient android:startColor="@android:color/transparent" android:centerColor="#33333333" android:endColor="#aa666666"

How to disable the background color when HomeUp is pressed?

天涯浪子 提交于 2019-12-19 04:10:28
问题 Background: I currently enable the HomeUp button on Activity , thanks to: getSupportActionBar().setDisplayHomeAsUpEnabled(true); According to the Documentation, it's related to setHomeButtonEnabled which: Enables or disables the "home" button in the corner of the action bar [...] Setting the constant DISPLAY_HOME_AS_UP display option (setDisplayHomeAsUpEnabled method) will automatically enable the home button. Also, I customize with a selector the state background of items in ActionBar with

Android: Make multiline edittext scrollable, disable in vertical scroll view

送分小仙女□ 提交于 2019-12-19 04:09:44
问题 I am developing an application in which i am struct at a point. As according to my application requirement i created horizontal scrollview in xml and then vertical scrollview in .java as : // Vertical Scroll view in Linear layout ScrollView scrollView = new ScrollView(this); scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); Then i created a table view programatically and added it in scrollview. I created multiline edit text and disable it