2017-12-23 10 views
-4

タイトルの上にLinearLayoutを作成する必要があります。このようなものです https://imgur.com/Kwa7a47
誰もこのようにする方法を知っていますか?編集カスタムLinearLayoutを作成するにはどうすればよいですか?

: は、ここで私は私のレイアウトの背景

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 

<corners 
    android:topRightRadius="30dp" 
    android:bottomLeftRadius="30dp" /> 
<stroke 
    android:width="2dp" 
    android:color="#000000"/> 
</shape> 
+0

あなたのイメージをロードすることはできませんが、私は以下にanwerを投稿してください。私はそれがあなたに役立つことを願っています – Hossein

+0

申し訳ありませんが、基本的には、TextViewを使ってLinearLayoutを作成しています。 TextViewの位置が境界の上にあります。ここに新しいリンクhttps://ibb.co/jCDC26 –

+0

私は役に立つかもしれないいくつかの変更。 drawable xmlファイルを作成し、Linearlayoutの背景として設定する必要があります。 – Hossein

答えて

1

あなたはLinerlayoutから延びるクラスを作成することができるように設定私のボーダー描画可能です。 onCreateメソッドでは、xmlレイアウトを拡張します。

public class ValueSelector extends Linerlayout { 

View rootView; 
TextView valueTextView; 

public ValueSelector(Context context) { 
    super(context); 
    init(context); 
} 

public ValueSelector(Context context, AttributeSet attrs) { 
    super(context, attrs); 
    init(context); 
} 

private void init(Context context) { 
    //do setup work here 
    rootView = inflate(context, R.layout.your_custom_view, this); 
} 
} 

その後your_layout_view.xmlにカスタムビューを作成するように:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="@drwable.boarder_bd" 
tools:context=".LinearLayout" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="My Data" 
      android:paddingTop="10px"/> 
</LinearLayout> 
+0

ありがとう、私は水曜日にそれを試してみます –

+0

あなたの答えをありがとう、しかし私が必要とするタイトルは、私が送った絵のように、国境の上にある必要があります。 –

関連する問題