2016-07-05 9 views
3

私はAndroid用の簡単なチャットアプリケーション(ネイティブSDKを使用して)を構築しようとしていますが、特にEditTextとTextView要素のためのUIの素敵なレイアウトを構成する上で問題があります。私は、AndroidのためのWhatsAppのアプリケーションのようなものを作成したいと思います:TextViewとEditTextのようなWhatsappを作成するにはどうすればよいですか?

enter image description here

目標は、要素の両方で、この先のとがった縁部を有する形状を作成することです。いくつかの調査をして、形状タグを使ってリソースファイルを構造化し、それをandroid:background属性に追加する必要があることを知りました。しかし、私はちょうどイメージのようにそれらの尖ったエッジを作成しようとしているのか分かりません。どんな助けもありがとう!

+1

私は(可能であれば)それが形としてこれを行うにはかなり複雑なことだと思います。この背景を作成する方がはるかに簡単です[9-PNG PNG](https://developer.android.com/guide/topics/resources/drawable-resource.html#NinePatch)。 –

+1

これを手作業でカスタムDrawableとして描くこともできますが、誰かに背景画像(Photoshopなど)をモックアップさせてEditTextのバックグラウンドとして設定する方が簡単かもしれません。 – NoChinDeluxe

+1

9パッチは、ilustratorや他のイメージエディタで画像を作成し、必要に応じてボーダーやコーナーの右上を作成し、Androidスタジオで9パッチを作成します – Adonys

答えて

0
<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" 
    android:orientation="vertical"> 

<ListView 
    android:background="#f1f1f1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
</ListView> 

    <LinearLayout 
     android:padding="10dp" 
     android:gravity="center" 
     android:weightSum="1" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true"> 

     <EditText 
      android:paddingBottom="3dp" 
      android:layout_marginRight="10dp" 
      android:layout_weight=".70" 
      android:layout_width="match_parent" 
      android:layout_height="45dp" 
      android:background="@drawable/lgbg" 
      android:hint="Add item" /> 

     <ImageView 
      android:layout_gravity="center" 
      android:foregroundGravity="center" 
      android:padding="13dp" 
      android:background="@drawable/send" 
      android:layout_weight=".30" 
      android:layout_width="70dp" 
      android:layout_height="50dp" 
      android:src="@drawable/ic_send_white" /> 

    </LinearLayout> 

+0

これは疑問に答えるかもしれませんが、答えの本質的な部分を説明し、おそらくOPコードの問題点を説明する方が良いでしょう。 – pirho

関連する問題