android-xml

NumberFormatException when using styleable attrs

六月ゝ 毕业季﹏ 提交于 2019-12-08 03:29:49
问题 I created a custom view for Android which renders two inner views to store a key and a value in two columns. The class looks like this: public class KeyValueRow extends RelativeLayout { protected TextView mLabelTextView; protected TextView mValueTextView; public KeyValueRow(final Context context) { super(context); init(context, null, 0); } public KeyValueRow(final Context context, final AttributeSet attrs) { super(context, attrs); init(context, attrs, 0); } public KeyValueRow(final Context

How to create a custom shape for a Button

此生再无相见时 提交于 2019-12-08 03:12:26
问题 How to create a custom shape for a Button? Can I set different colors to button background colors for many conditions.Any help will be appreciated.Thanks. 回答1: How to create a custom shape for a Button? Create a test.xml file in drawable and add code: <?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/one"> //<---- id is must for color change <shape android:shape="rectangle"> <size android:width="150dp"

ANDROID Rendering problems NullException

寵の児 提交于 2019-12-08 03:04:26
问题 I am a newbie in android programming. I tried to create a stopwatch application, but recently i got an error in the layout. I have been debugging this layout error for 2 days and still cannot find the solution. I do not think this is IDE problem because when i tested it using my phone, the program stopped(error). Please take a look of the error below: java.lang.NullPointerException at android.widget.LinearLayout.forceUniformHeight(LinearLayout.java:1380) at android.widget.LinearLayout

eclipse don't recognize my sony xperia mini pro for debuging program directly

女生的网名这么多〃 提交于 2019-12-08 01:34:33
问题 i have installed: 1:sony ericsson pc companion 2:SEMC_Signed usb Driver 3.updated my eclipse->available packages.. but while running program it will not detect the phone? 回答1: A few things to try: Make sure you don't have one of those cheap $2 knockoff USB interface cables. I banged my head for an hour or two before I realized the reason my PC wouldn't see my phone is because of my cable. Drop to command prompt, type adb kill-server and then adb devices to restart the adb server. Make sure

How to customize style from spinner dropdown CHOICES?

谁说胖子不能爱 提交于 2019-12-08 01:06:00
问题 I can customize the background of the selected option on a spinner dropdown using: <item name="android:spinnerStyle">@style/customSpinner</item> <style name="customSpinner" parent="@android:style/Widget.Holo.Light.Spinner"> <item name="android:textColor">#000000</item> <item name="android:background">#000000</item> </style> But I can't manage to change the background and textcolor of the list of options that the dropdown has. How do I achieve that? 回答1: adapter.setDropDownViewResource(R

android:foreground attribute / setForeground() method does not work with Button elements

梦想的初衷 提交于 2019-12-08 00:49:53
问题 Since Android 23, the android:foreground XML attribute (and corresponding setForeground() method) should be available to all Views, and not just FrameLayout instances as was previously the case. Yet, for some reason, whenever I create a Button instance which inherits from TextView -> View, I can't seem to get a foreground to show at all. Here is an example button definition that doesn't work appear to show the foreground: <Button android:layout_width="match_parent" android:layout_height="wrap

Elements in Relative Layout showing differently when the app runs

无人久伴 提交于 2019-12-07 18:38:06
问题 I have a ListView created inside a fragment, and it has a search filter, the problem is XML layout showing fine in android studio but when running in the emulator or phone it's showing differently (not properly as I aligned) and also when I click the SearchView it goes under the tab navigation. Can anyone tell how to fix this? This is the fragment: import android.content.Context; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View;

Android place an image view between two views

…衆ロ難τιáo~ 提交于 2019-12-07 18:35:14
问题 I need to create a layout as shown in the image. The rounded button with the arrow needs to be exactly between the blue and the gray background. I'm having difficulties placing it without specifying the margins precisely, which is something I don't want to do because there is no guarantee it will look good on all resolutions and devices. I would appreciate an xml sample for that Thanks! 回答1: Use the desired drawable.. hope it works.. you can set width and height according to your need. <?xml

Why is my floating action button not displaying its image properly?

▼魔方 西西 提交于 2019-12-07 11:13:03
问题 This is what my floating action button is showing rather that just showing the actual circle part of the image, it tries to fit the background of my .png file into the floating action button. here is my xml code: <android.support.design.widget.FloatingActionButton android:id="@+id/addToKitchenButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:layout_gravity="bottom|end" android:layout_alignParentBottom="true" android:layout

How to stop main content re-sizing of umano AndroidSlidingUpPanel when panel is set to default panel height

一世执手 提交于 2019-12-07 08:00:20
问题 I am using umano AndroidSlidingUpPanel in my Android project. Here I am using Google Map as my main content. Follow is the relevant XML file. <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" tools:context=".DemoActivity" > <com.mypkg.name.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto" android:id="@+id/sliding_layout"