Xamarin.Androidでビューを使用する
ご覧のページは、お客様の利便性のために一部機械翻訳されています。また、ドキュメントは頻繁に更新が加えられており、翻訳は未完成の部分が含まれることをご了承ください。最新情報は都度公開されておりますため、必ず英語版をご参照ください。翻訳に問題がある場合は、こちらまでご連絡ください。
Liferay Screens View を使用して、スクリーンレットのコア機能に依存しないスクリーンレットのルックアンドフィールを設定できます。 Liferayのスクリーンレットにはいくつかのビューがあり、Liferayとコミュニティによってさらに多くのビューが開発されています。 Screenletリファレンスドキュメント は、Screensに含まれる各Screenletで利用可能なビューがリストされています。 このチュートリアルでは、Xamarin.Androidでビューを使用する方法を示します。
ビューとビューセット
XamarinのLiferay Screensのビューとビューセットを構成する概念とコンポーネントは、Liferay Screens for Androidのものと同じです。 これらのコンポーネントの簡単な説明については、 ビューとビューセットのセクション ビューの使用に関する一般的なチュートリアルを。 Liferay ScreensのViewレイヤーの詳細な説明については、チュートリアル AndroidのLiferay Screensのアーキテクチャ参照してください。
ビューを使用する
Xamarin.Androidでビューを使用するには、次の手順に従います。
-
使用するビューのレイアウトを Liferay Screensリポジトリ からアプリの
res / layout
フォルダーにコピーします。 または、新しいレイアウトを作成できます。 次のリンクは、各ビューセットで使用可能なビューレイアウトを示しています。たとえば、これはログインスクリーンレットのマテリアルビュー、
login_material.xml
です。<com.liferay.mobile.screens.viewsets.material.auth.login.LoginView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:liferay="http://schemas.android.com/apk/res-auto" android:paddingLeft="40dp" android:paddingRight="40dp" style="@style/default_screenlet"><LinearLayout android:id="@+id/basic_authentication_login" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout style="@style/material_row"> <ImageView android:id="@+id/drawable_login" android:contentDescription="@string/user_login_icon" android:src="@drawable/material_email" style="@style/material_icon"/> <EditText android:id="@+id/liferay_login" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="8dp" android:inputType="text" android:labelFor="@+id/liferay_login"/> </LinearLayout> <LinearLayout style="@style/material_row"> <ImageView android:id="@+id/drawable_password" android:contentDescription="@string/password_icon" android:src="@drawable/material_https" style="@style/material_icon"/> <EditText android:id="@+id/liferay_password" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="8dp" android:hint="@string/password" android:inputType="textPassword"/> </LinearLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="32dp"> <Button android:id="@+id/liferay_login_button" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:text="@string/sign_in"/> <com.liferay.mobile.screens.base.ModalProgressBar android:id="@+id/liferay_progress" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center_vertical|left" android:layout_margin="10dp" android:theme="@style/white_theme" android:visibility="invisible" liferay:actionViewId="@id/liferay_login_button"/> </FrameLayout> </LinearLayout> <Button android:id="@+id/oauth_authentication_login" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/authorize_application" android:visibility="gone"/> </com.liferay.mobile.screens.viewsets.material.auth.login.LoginView>
-
Screenletを表示するアクティビティまたはフラグメントのレイアウトにScreenletのXMLを挿入する場合、
liferay:layoutId
属性をビューのレイアウトに設定します。 たとえば、liferay:layoutId を設定したLogin ScreenletのXMLは <code>@ layout / login_material
に設定されています。これは、前のステップのLogin Screenletのマテリアルビューを指定します。<com.liferay.mobile.screens.auth.login.LoginScreenlet android:id="@+id/login_screenlet" android:layout_width="match_parent" android:layout_height="match_parent" liferay:layoutId="@layout/login_material" />
-
使用するビューがビューセットの一部である場合(たとえば、マテリアルビューがマテリアルビューセットの一部である場合)、アプリまたはアクティビティのテーマも、そのビューセットのスタイルを定義するテーマを継承する必要があります。 たとえば、アプリの
Resources / values / Styles.xml
の次のコードは、AppTheme.NoActionBar
に、マテリアルビューセットを親テーマとして使用するように指示します。