WearOSのレイアウトに取り組んでいますが、問題が発生しています。ListViewがあり、ListViewの各行(TextView)が画面全体を占めています。次に、各TextViewの下部にアイコンを配置します。私の目標は、次のようになることです。
現在、各行にアイコンを表示する以外に、必要なものはすべて揃っています。インポートしましたが、XMLの定義方法がわかりません。他のStackOverFlowの質問を試しましたが、機能させることができませんでした。カスタムアダプターにも自信があります。困っているのはレイアウトです。私はレイアウトに慣れていないので、レイアウトを理解できなかったことが問題になっています。Androidレイアウトがどのように機能するかを説明するチュートリアルに従ってみましたが、何らかの理由で取得できません。
ListViewのXMLは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<!-- Defines the layout for the ListView-->
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/goals_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</android.support.constraint.ConstraintLayout>
また、ListViewの各行のXMLは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<!-- Defines the layout for a row in the ListView-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<TextView
android:id="@+id/goal_row"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="-"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold" >
</TextView>
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/info_icon"
/>
</LinearLayout>
これらのレイアウトを使いたいので、私がすでに持っているものを手伝ってください。私がやろうとしていることを行うための別の方法についての提案があれば、私は提案を受け入れますが、これが私がそれを実装する方法です。助けてくれてありがとう。
次のことを試してください。
<?xml version="1.0" encoding="utf-8"?>
<!-- Defines the layout for a row in the ListView-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
>
<TextView
android:id="@+id/goal_row"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello W"
android:layout_above="@id/base"
android:layout_alignParentTop="true"
android:gravity="center"
android:layout_centerHorizontal="true"
android:textSize="20sp"
android:textStyle="bold" >
</TextView>
<ImageView
android:id="@+id/icon"
android:layout_above="@id/base"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"/>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/base"
android:layout_alignParentBottom="true">
</View>
</RelativeLayout>
出力: - - - -
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加