android-ui

Using “merge” and “include”

怎甘沉沦 提交于 2019-12-13 15:22:35
问题 I'm trying to put a copyright image in the bottom of my LinearLayout with an "include tag". I am doing it successfully, but when I'm trying to add android:layout_marginTop="330dp" or android:layout_marginBottom="20dp" for instance to my include - it doesn't show in the UI. What is the problem ? Here is my code: copyrights.xml: <merge xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:src="@drawable/copyrights" android:id="@+id/copyrights" android:layout_width="fill

Android IllegalArgumentException: Wrong state class if the app was background for a period of time

送分小仙女□ 提交于 2019-12-13 15:18:50
问题 I think it is due to low memory if I set the app background. The log is like below: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.qingdaonews.bus/com.qingdaonews.activity.RealTime}: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.view.View$BaseSavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/myviewpager. Make sure other views do

Android: Is there a way to change the height of switch button?

a 夏天 提交于 2019-12-13 14:20:01
问题 The switch height looks really small on a tablet. Is there a way, we can increase the height? If we increase it by giving a value to layout_height, it just add some blank space at the bottom, but the switch size doesnt increase. 回答1: you can try this: android:thumbTextPadding="25dp" android:switchMinWidth="56dp" android:track="@drawable/custom_grey_image" 回答2: The @dipali answer is righthere is a small example how to change your swicth width, i hope it will help some one.. 1)Use ur color for

How to design a spinner in Android

会有一股神秘感。 提交于 2019-12-13 12:59:19
问题 I want to design a spinner as displayed in the image below: I am not getting the arrow symbol pointing downside in spinner. How can I do this? If I make a button design like shown above then I have to write extra code to get similar functionality as for a spinner, as Spinner doesn't have android:drawableRight="@drawable/arraodown" , but in the button we have this method. 回答1: Do not mess around with right/left/... drawables. Just set one 9-patch drawable as background that limits the inner

Android ListView-like scrolling WITHOUT the ListView

守給你的承諾、 提交于 2019-12-13 03:22:52
问题 I've been Googling like crazy for a while now, and I simply can't find any answers to the question: is it possible to implement the Android List scrolling, without using an actual list UI? I'm trying to make a grid of rectangles such as the kind you would find in a typical game app respond to finger movement in the same way that it does using Android lists (bounce on the bounds, the 'flick' effect, etc), but all of the approaches I've found involve over-complicated solutions involving

Replace the action bar's title with a spinner (drop down)

荒凉一梦 提交于 2019-12-12 08:29:38
问题 I am trying to display a spinner in the same position where the action bar's default title appear. I followed the instruction of the similar SO case here , so I managed to eliminate the title but still the spinner's position is not aligned to the left, as you can see from this screen-shot Here are the main definitions of my application to reproduce this case: AndroidMenifest.xml: <application android:label="app" android:icon="@drawable/ic_launcher" android:theme="@style/Theme.AppCompat" > ...

How to Handle Button Clicks ListFragment

你离开我真会死。 提交于 2019-12-12 05:49:10
问题 I was curious how best to handle button clicks, inside of a ListFragment with a custom adapter. I have an onClickListener setup for the buttons, but I need to be able to get the item that it was clicked from, since it is within an item, here is the getView inside the custom adapter. */ @Override public View getView(int position, View convertView, ViewGroup parent) { View view; if (convertView == null) { view = _inflater.inflate(R.layout.test_single_item, parent, false); } else { view =

adding custom font in my app

旧时模样 提交于 2019-12-12 04:48:20
问题 while adding custom font in my app, it's crashing some time. But most of the time it get executed smoothly. i'm using following code. try { // Get the typeface ShravyaApp.appTypeFace = Typeface.createFromAsset(getApplication().getAssets(), "kadage.ttf"); Log.d("font","in type="+ShravyaApp.fontName); Log.d("font","type face="+ShravyaApp.appTypeFace); } catch (Exception e) { ShravyaApp.appTypeFace = Typeface.createFromAsset(getApplication().getAssets(), "kadage.ttf"); Log.d("font","in catch

Prevent Android Service From Being Killed By OS

ぃ、小莉子 提交于 2019-12-12 02:36:00
问题 I have created a service that is returning START_STICKY at the onStartCommand. However, after sometime, I notice that my app has been killed by the OS. Is there any method/piece of code that I can use to prevent the app from being killed by the OS? I know this may not fall under the best practices. Or is there some other method that we can use like repeatedly check if the app is running, and to start the app if it is not? Your insight on this is very much appreciated. Cheers 回答1: You cannot

Multiple and Repetitive AsyncTask in Android

血红的双手。 提交于 2019-12-12 00:55:47
问题 I have two asynctask working with each other. I'm using them for creating Restaurant menu. First web service gets menu's titles from database. Second web service gets items of title from database. I get title data in my first asynctask and item data in my second asynctask. For example, I have ten menu titles. There are eight items for each title. I execute first asynctask and get all of menu titles. I want to call second asynctask in first asynctask's onPostExecute for get this title's item