android-xml

How to get distance from the View to a phone bottom?

家住魔仙堡 提交于 2019-12-22 08:14:51
问题 If I have a certain View on the layout ( ImageView , for example), is it possible to find the distance from the bottom border of the View to the bottom of the phone screen? Thanks. 回答1: // instantiate DisplayMetrics DisplayMetrics dm = new DisplayMetrics(); // fill dm with data from current display getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); // loc will hold the coordinates of your view int[] loc = new int[2]; // fill loc with the coordinates of your view (loc[0] = x,

Is there a way to use a variable ad banner size?

China☆狼群 提交于 2019-12-22 07:10:33
问题 I'm using Android MOB, and I'd like to use different sizes of banners, especially for the larger screen sizes. I'm using XML code to do so. Is there a way I can use XML to make it work? I'd like to use XML so I can just put it as a standard part of my styles for each of the screen sizes. Thanks! Sample XML Code: <com.google.ads.AdView android:id="@+id/adView" ads:loadAdOnCreate="true" ads:adSize="BANNER" ads:adUnitId="@string/admob_unit_id" android:layout_width="wrap_content" android:layout

XML Layout - Entry Identifier 0x11a is larger than entry count 0xb2

好久不见. 提交于 2019-12-22 05:35:34
问题 'Entry Identifier 0x11a is larger than entry count 0xb2' This is what's printed in my LogCat when switching to a specific fragment. I think it may have something to do with my 'xml layout' resource being inflated. I am not sure what though. My Question Has anybody else had this problem or know what it means? Thanks for your help 回答1: I've encountered this problem and worked around it with a hack. I added an empty style at the top of my styles.xml: <style name="empty_style" /> According to

EditText - Gap between text and EditText's line

邮差的信 提交于 2019-12-22 03:36:51
问题 When I insert text to my EditText field the text has an abnormal gap between itself and the EditText 's line. Here's a printscreen from my terminal where you can see this gap I'm talking about, it is marked in red. I've played around with text alignment and gravity but to no success. Here's the XML: <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"

EditText - Gap between text and EditText's line

倾然丶 夕夏残阳落幕 提交于 2019-12-22 03:36:20
问题 When I insert text to my EditText field the text has an abnormal gap between itself and the EditText 's line. Here's a printscreen from my terminal where you can see this gap I'm talking about, it is marked in red. I've played around with text alignment and gravity but to no success. Here's the XML: <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"

How to make option menu appear on bottom of the screen?

核能气质少年 提交于 2019-12-22 02:17:08
问题 Here is what I am trying to implement: when people click on the menu on top right corner of a toolbar, an options menu appears on bottom of the screen. See picture below: I am not sure what method should I call for the item at the bottom. Can somebody give me some hint on how to implement this? I implement successfully the icon in the top right menu bar with the code below. But I don't know how to show the options at the bottom of the screen, with width match_parent , and height wrap_content

Android Dim Background of Custom Dialog

試著忘記壹切 提交于 2019-12-21 13:03:16
问题 As titled, I cannot seem to be able to dim the background of the custom dialog box I have made. Countless solutions online mention the last 3 lines of code in the first snippet below, this has made no impact on the UI of the dialog box. See the following code: Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog); TextView textView = (TextView) dialog.findViewById(R.id.textView); textView.setText("Custom

Android: Default XML Editor isn't opening anymore [Unsupported Content Type Error]

坚强是说给别人听的谎言 提交于 2019-12-21 04:18:08
问题 I've been using Eclipse for developing apps in android for quite some time. I updated the Android SDK Platform to 3.0, API 11 recently. Now I'm unable to open the AndroidManifest.xml or any other XML files in the Layout folder by double clicking. When I double click any XML file (like main.xml / strings.xml), I get the "Unsupported Content Type" error. http://www.freeimagehosting.net/uploads/67e93ddb8a.png Is there any way to solve this problem? P.S: If I open the xml files with "Open With ->

Rectangle shape with two solid colors

蹲街弑〆低调 提交于 2019-12-21 04:16:38
问题 I'd like to create a rectangle shape with two solid colors (horizontally) to achieve something like this: I heard about layer-list , i though i could use it to contains two rectangle with a different color but it seems that it only lays shapes vertically. Is there a way to achieve this using lalyer-list or should i use something totally different? I'd like to keep it simple with ability to change the shape colors at runtime. Thanks. 回答1: You can create custom drawable for this. Just extend

No resource identifier found for attribute 'showAsAction' in package 'android'

心已入冬 提交于 2019-12-21 03:44:06
问题 as the title suggest, I'm getting that error in at least 3 of the XML layout files, however, I dont see the attritube "showsAsAction" in any of those XML files, did I miss something or am I just blind?, here are the XML files in question: <?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:orientation="vertical" > <Button android:id="@+id/findSelected"