私はAndroidでそのようなフォームを実行することが可能かどうか知りたいです:
この時点で、境界線を作成するための形状を作成しました(この形状を線形レイアウトの背景として使用しますが、テキストの処理方法がわかりません)。
前もって感謝します。
次のテクニックを使用して、タイトル付きのフレームを取得することができました。
FrameLayout
全体のレイアウトに使用します。
内部にメインコンテンツの別のレイアウトを追加します-これは何でもかまいません。このレイアウトの背景には、で描画可能なカスタムXMLを使用しstroke
てフレームを描画します。marginTop
特に、フレームのタイトルを表示するためのスペースが必要なため、このレイアウトには必ずマージンを追加してください。また、見栄えを良くするためにパディングを追加します。
TextView
タイトルとして不透明な背景といくつかのパディングで使用します。marginLeft
タイトルを左からオフセットするために、適切な値に設定します。
これが私のXMLです:
<?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="fill_parent"
android:background="@android:color/white">
<!-- This is the main content -->
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_margin="15dp" android:background="@drawable/frame"
android:orientation="vertical" android:padding="20dp">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Main Content" android:layout_centerInParent="true" />
</RelativeLayout>
<!-- This is the title label -->
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/white" android:padding="5dp"
android:text="Testing"
android:layout_marginLeft="30dp" android:textColor="@android:color/black" />
</RelativeLayout>
実行すると、アプリでこれを取得します。
余白/パディングを自由に調整して、タイトルを必要な方向に揃えてください。