Androidのボタン - 他の長方形に入れ長方形

Elikill58:

(前に私がグーグル、Redditにと不和のコミュニティサーバーにそれを聞いて、ここに来て、私は任意の応答を受信しません)。私は(例)のように、ボタンのカスタムデザインを作りたいです。

ここでは、画像の説明を入力します。

私は(形状)デフォルトのデザインを編集する方法を知って、私は1つの四角形を作るためにsuccededが、私は、同じ形状の2番目の四角形を追加できませんでした。

AndroWaqar:

あなたはこのように行うことができます

では、main_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout 
        android:onclick="onclickbtn"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:background="@android:color/darker_gray">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:textSize="18sp"
            android:layout_centerInParent="true"
            android:textColor="@android:color/white"
            android:text="My Text Button"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_alignParentEnd="true"
            android:textColor="@android:color/white"
            android:text="new"
            android:background="@android:color/holo_blue_light"/>

    </RelativeLayout>
</RelativeLayout>

onclickのは、Main_activity.java

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    public void onclickbtn(View view) {
        Toast.makeText(this, "Button Clicked", Toast.LENGTH_SHORT).show();
    }

    public void OnClickRide(View view) {
        Toast.makeText(this, "Ride Button Clicked", Toast.LENGTH_SHORT).show();
    }


}

出力: 出力

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=361689&siteId=1