2016-09-10 4 views
0

私はネイティブのアンドロイドでボタンとエディットテキストをデザインしようとしていますが、実際のUIを作成することはできません。このようなUIを作成するにはどうすればいいですか?イメージでは、最初のフィールドは入力ボックスとして機能し、2番目のフィールドはボタンとして機能するはずです。 enter image description hereボタンとedittextのカスタムUI

+0

いくつかのカスタムドロワブルが必要ですが、丸い角を持つ2つのフィールド上のフローティングアクションボタンのように見えます。どのくらいの長方形の角の丸みをつけようとしていますか?後でサークルについて心配して –

答えて

1

次のxmlは、同じUIを作成します。 :)

  1. <?xml version="1.0" encoding="utf-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="#eeC4C6C7" /> 
    <corners android:bottomRightRadius="30dp" 
    android:bottomLeftRadius="30dp" 
    android:topRightRadius="30dp" 
    android:topLeftRadius="30dp"/> 
    </shape> 
    
  2. の下に与えられた、描画可能なフォルダにroundedbutton.xmlリソースファイルを作成

    <?xml version="1.0" encoding="utf-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="#eeCD3E22" /> 
    <corners android:bottomRightRadius="30dp" 
    android:bottomLeftRadius="30dp" 
    android:topRightRadius="30dp" 
    android:topLeftRadius="30dp"/> 
        </shape> 
    
の下に与えられた、描画可能なフォルダにroundededittext.xmlリソースファイルを作成します

メインのxmlレイアウトファイルを作成します。私はあなたのcustume Edittextで作成しました

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_margin="20dp"> 

<ImageButton 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:background="@drawable/roundedbutton" 
    android:elevation="10dp" 
    android:layout_gravity="center_vertical" 
    android:text="t" 
    /> 
<EditText 
    android:layout_width="match_parent" 
    android:layout_height="45dp" 
    android:layout_marginLeft="-30dp" 
    android:elevation="2dp" 
    android:layout_gravity="center_vertical" 
    android:background="@drawable/roundededittext"/> 

    </LinearLayout> 

希望します!疑いの余地はない。

+1

ありがとう。あなたのアイデアは私を大いに助けました! – JohnC

関連する問題