How to create buttons?

Does anyone know if there is a way to create android buttons like this:

Like this.

+4
source share
5 answers

try it

<Button android:drawableTop="@drawable/icon" android:background="@android:color/transparent"/> 

Alternatively, you can create this bottom byte of this type using Tab in android

Press here

You can also create this type of button using the radio button.

Press here

+3
source

I would say that these are ordinary buttons with a transparent background and icons set via drawableTop . So, the xml for such a button will look like this:

 <Button android:drawableTop="@drawable/icon" android:background="@android:color/transparent"/> 
+4
source

To do this, it seems to me, you need to create a custom view for the tab and call tabjttp: //joshclemm.com/blog/?p=136

thanks

0
source

fine

- take one layout and align it ALIGNPARENTBOTTOM = TRUE now set the background of this layout for THIS BLACK

- now take the five buttons in this layout horizontally now take pictures like these Transparent and set it to the buttons

- also get images for the HOVER action and set it by pressing this button

(use layout_weight to set the same button size)

Enjoy!

0
source

I did the same in one of my applications. Here I give the xml code for this

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="60dp" android:background="#000" android:gravity="center_vertical"> <LinearLayout android:layout_width="60dp" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/reviewLayout" android:gravity="center_horizontal" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/reviews" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Review" android:textColor="#FFF"/> </LinearLayout> <LinearLayout android:layout_width="60dp" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/nearbyLayout" android:layout_toRightOf="@id/reviewLayout" android:gravity="center_horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="30dp" android:src="@drawable/nearby"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Nearby" android:textColor="#FFF"/> </LinearLayout> <LinearLayout android:layout_width="60dp" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/searchLayout" android:layout_toRightOf="@id/nearbyLayout" android:gravity="center_horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="30dp" android:src="@drawable/search"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Search" android:textColor="#FFF"/> </LinearLayout> <LinearLayout android:layout_width="75dp" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/bookmarkLayout" android:layout_toRightOf="@id/searchLayout" android:gravity="center_horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="30dp" android:src="@drawable/bookmarks"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Bookmarks" android:textColor="#FFF"/> </LinearLayout> <LinearLayout android:layout_width="60dp" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/settingsLayout" android:layout_toRightOf="@id/bookmarkLayout" android:gravity="center_horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="30dp" android:src="@drawable/settings"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Settings" android:textColor="#FFF"/> </LinearLayout> </RelativeLayout> 

Use this layout where you want to use the include tag and call it in your activity. Here I give the code to include this in an Activity.

 private LinearLayout reviewLay,nearbyLay, searchLay, bookmarkLay, settingLay; reviewLay = (LinearLayout)findViewById(R.id.reviewLayout); nearbyLay = (LinearLayout)findViewById(R.id.nearbyLayout); searchLay = (LinearLayout)findViewById(R.id.searchLayout); bookmarkLay = (LinearLayout)findViewById(R.id.bookmarkLayout); settingLay = (LinearLayout)findViewById(R.id.settingsLayout); reviewLay.setOnClickListener(this); nearbyLay.setOnClickListener(this); searchLay.setOnClickListener(this); bookmarkLay.setOnClickListener(this); settingLay.setOnClickListener(this); btEdit.setOnClickListener(this); 

Here, I used a layout instead of a button, and I set onclicklistener for each layout. Now override the onclick method and do what you want with each layout

0
source

Source: https://habr.com/ru/post/1369111/


All Articles