android-layout

How to get line count of textview before rendering?

天涯浪子 提交于 2020-01-09 09:04:07
问题 How can I get the number of lines a string will take up in a TextView before it is rendered. A ViewTreeObserver will not work because those are only fired after it is rendered. 回答1: final Rect bounds = new Rect(); final Paint paint = new Paint(); paint.setTextSize(currentTextSize); paint.getTextBounds(testString, 0, testString.length(), bounds); Now divide the width of text with the width of your TextView to get the total number of lines. final int numLines = (int) Math.ceil((float) bounds

Full width Navigation Drawer

痞子三分冷 提交于 2020-01-09 08:56:08
问题 I'd like to create a full width navigation drawer. Setting layout_width to match_parent on @+id/left_drawer yields in width of about 80% of screen space. This seems to be the standard behavior. Do I have to override onMeasure() of DrawerLayout ? My current code: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match

Change basic theme color of android application

ε祈祈猫儿з 提交于 2020-01-09 08:14:32
问题 Every android application/theme hast it's own basic theme color: HTC Desire Z - green, most Samsung deviced - yellow,... It's the color of selected list items, option menu-radio button, radio button, progress-bars,.... I know how to change these colors individual. But is there a way to change all of them by setting one value? Something like: <style name="my_theme" parent="@android:style/Theme.Black"> <item name="android:_DEFAULT_BASE_COLOR_1">#XXXXXX</item> </style> //EDIT: So I'm looking for

R.styleable can not be resolved, why?

与世无争的帅哥 提交于 2020-01-09 07:42:26
问题 I have a resources.xml file located under direcotry values/ , That's /values/resources.xml <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="TheMissingTabWidget"> <attr name="android:divider" /> </declare-styleable> </resources> In my java code, when I try to access this resource by R.styleable.TheMissingTabWidget , eclipse complain that styleable cannot be resolved or is not a field . Why? Why I can not access this resource? (I am using android 2.1-updated). 回答1:

How to get all apps installed on android phone

你离开我真会死。 提交于 2020-01-09 07:11:07
问题 This is the code that i have at the moment but i still can't get a list of all the apps on the phone. Does anyone see what i am doing wrong? public class GetAppList extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { List<PackageInfo> appListInfo1 = this.getPackageManager() .getInstalledPackages(0); JSONArray ja = new JSONArray(); try {

How to get all apps installed on android phone

落爺英雄遲暮 提交于 2020-01-09 07:10:08
问题 This is the code that i have at the moment but i still can't get a list of all the apps on the phone. Does anyone see what i am doing wrong? public class GetAppList extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { List<PackageInfo> appListInfo1 = this.getPackageManager() .getInstalledPackages(0); JSONArray ja = new JSONArray(); try {

How to send view to back ? How to control the z-order programmatically?

时间秒杀一切 提交于 2020-01-09 06:46:46
问题 I have a problem to send the view to back. In Android we have a method like bringToFront() , to place the view on top of the another view. Like that, I want to put the view on below the previous image. Is there any method like sendToBack() or bringToBack() in Android. If so, can any one help me in this. Note: that I do not want to control the z-order by the order of placing items in layout I want to control the z-order programmatically. I do not want to hide the views on the front I just want

Android:Textview with vertical scrolling text [duplicate]

﹥>﹥吖頭↗ 提交于 2020-01-09 06:17:10
问题 This question already has answers here : Making TextView scrollable on Android (28 answers) Closed 3 years ago . I am finding a tough time setting the textview with vertical scrolling text. In my dialog I have a textview with large text, since dialog is small window I want the textview text to scroll the vertically so that dialog looks good. Below is my xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

Android:Textview with vertical scrolling text [duplicate]

微笑、不失礼 提交于 2020-01-09 06:17:05
问题 This question already has answers here : Making TextView scrollable on Android (28 answers) Closed 3 years ago . I am finding a tough time setting the textview with vertical scrolling text. In my dialog I have a textview with large text, since dialog is small window I want the textview text to scroll the vertically so that dialog looks good. Below is my xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width=

Android Support Library v7: Error retrieving parent for item

北城以北 提交于 2020-01-09 04:38:40
问题 I am trying to build the Android Support Library v7 samples. For that, I created an sampleproject through Eclipse -> New Android Sample Project and added the android-support-v7-* projects as "Android Project From Existing Code" to Eclipse, and made the sample project reference them. But I am getting the following errors in android-support-v7-mediarouter/res/values/styles.xml : error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton