Rounded corners android image buttons

Use Shape in android to make the rounder corners create the xml file named it as roundcorner.xml <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <solid android:color=”#33DDFF” /> <corners android:radius=”4dp” /> </shape> In your ImageButton add this attribute android:background=”@drawable/roundcorner” <ImageButton android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:id=”@+id/imageButton” android:layout_marginTop=”57dp” android:src=”https://stackoverflow.com/questions/21633637/@drawable/friends” android:background=”@drawable/roundcorner” android:padding=”1dp” android:layout_alignParentTop=”true” android:layout_toLeftOf=”@+id/imageButton2″ android:layout_marginRight=”62dp” />

How to show the text on a ImageButton?

As you can’t use android:text I recommend you to use a normal button and use one of the compound drawables. For instance: <Button android:id=”@+id/buttonok” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:drawableLeft=”https://stackoverflow.com/questions/4457030/@drawable/buttonok” android:text=”OK”/> You can put the drawable wherever you want by using: drawableTop, drawableBottom, drawableLeft or drawableRight. UPDATE For a button this too works pretty fine. Putting android:background is … Read more

How do I keep the aspect ratio on image buttons in android?

<LinearLayout android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:id=”@+id/layoutButtons”> <com.package.SquareButton android:layout_height=”fill_parent” android:layout_width=”0dip” android:layout_weight=”1″ <ImageView android:id=”@+id/box1″ android:layout_gravity=”center” android:adjustViewBounds=”true” android:scaleType=”centerInside” android:layout_height=”wrap_content” android:layout_width=”0dp” android:layout_weight=”1″ android:layout_marginLeft=”5dp” android:layout_marginRight=”5dp”/> </com.package.SquareButton> <com.package.SquareButton android:layout_height=”fill_parent” android:layout_width=”0dip” android:layout_weight=”1″ <ImageView android:id=”@+id/box2″ android:layout_gravity=”center” android:adjustViewBounds=”true” android:scaleType=”centerInside” android:layout_height=”fill_parent” android:layout_width=”fill_parent” android:layout_marginLeft=”5dp” android:layout_marginRight=”5dp”/> </com.package.SquareButton> ……… </LinearLayout> And then add this custom button class: public class SquareButton extends LinearLayout { public SquareButton(Context context) { super(context); } public … Read more

jQuery UI Dialog – missing close icon

I am late to this one by a while, but I’m going to blow your mind, ready? The reason this is happening, is because you are calling bootstrap in, after you are calling jquery-ui in. Literally, swap the two so that instead of: <script src=”http://code.jquery.com/ui/1.10.3/jquery-ui.js”></script> <script src=”https://stackoverflow.com/questions/17367736/js/bootstrap.min.js”></script> it becomes <script src=”https://stackoverflow.com/questions/17367736/js/bootstrap.min.js”></script> <script src=”http://code.jquery.com/ui/1.10.3/jquery-ui.js”></script> 🙂 Edit … Read more

Can’t click on ListView row with imagebutton

Unfortunately, android:focusable=”false” android:focusableInTouchMode=”false” doesn’t work for ImageButton. I finally found the solution here. In your layout xml for those items, add android:descendantFocusability=”blocksDescendants” to the root view. It works perfectly for a ListView that has ImageButtons. According to official reference, blocksDescendants means that the ViewGroup will block its descendants from receiving focus.

Difference between a clickable ImageView and ImageButton

There’s no differences, except default style. ImageButton has a non-null background by default. EDIT: Also, ImageButton.onSetAlpha() method always returns false, scaleType is set to center and it’s always inflated as focusable. Here’s ImageButton‘s default style: <style name=”Widget.ImageButton”> <item name=”android:focusable”>true</item> <item name=”android:clickable”>true</item> <item name=”android:scaleType”>center</item> <item name=”android:background”>@android:drawable/btn_default</item> </style>