Disable soft keyboard on NumberPicker

I’m trying to deactivate the soft keyboard when using a NumberPicker to enter numerical values (for aesthetic reasons). This is my layout-xml-code: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > <LinearLayout android:id=”@+id/linearLayout2″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center_horizontal” android:layout_marginBottom=”30dp” android:layout_marginTop=”30dp” > <NumberPicker android:id=”@+id/repetitionPicker” android:layout_width=”40dp” android:layout_height=”wrap_content” /> <TextView android:id=”@+id/textView1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center_vertical” android:text=”@string/repetitions_short_divider” android:textAppearance=”?android:attr/textAppearanceMedium” /> <NumberPicker android:id=”@+id/weightPicker” android:layout_width=”40dp” … Read more

Android How to adjust layout in Full Screen Mode when softkeyboard is visible

I have researched a lot to adjust the layout when softkeyboard is active and I have successfully implemented it but the problem comes when I use android:theme=”@android:style/Theme.NoTitleBar.Fullscreen” this in my activity tag in manifest file. For this I have used android:windowSoftInputMode=”adjustPan|adjustResize|stateHidden” with different options but no luck. After that I implemented FullScreen programmatically and tried … Read more

Handling click events on a drawable within an EditText

I have added an image right of the text in an EditText widget, using the following XML: <EditText android:id=”@+id/txtsearch” … android:layout_gravity=”center_vertical” android:background=”@layout/shape” android:hint=”Enter place,city,state” android:drawableRight=”@drawable/cross” /> But I want to clear the EditText when the embedded image is clicked. How can I do this? 41 Answers 41 Actually you don’t need to extend any class. … Read more

Add padding on view programmatically

I am developing Android v2.2 app. I have a Fragment. In the onCreateView(…) callback of my fragment class, I inflate an layout to the fragment like below: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.login, null); return view; } The above inflated layout file is (login.xml): <?xml version=”1.0″ encoding=”utf-8″?> … Read more

Set ImageView width and height programmatically?

How can I set an ImageView‘s width and height programmatically? 15 s 15 It may be too late but for the sake of others who have the same problem, to set the height of the ImageView: imageView.getLayoutParams().height = 20; Important. If you’re setting the height after the layout has already been ‘laid out’, make sure … Read more