アプリの作成画面を作成しています。ユーザーがメッセージを入力する場所と、ステータスに画像が添付されてScrollView
いるかどうかに応じて表示のオンとオフが切り替えられる です。これが私のレイアウト XML の一部です。RelativeView
EditText
ImageView
<!-- @dimen/bigGap = 8dp -->
<ScrollView android:id="@+id/parentScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_marginTop="@dimen/bigGap"
android:layout_marginRight="@dimen/bigGap"
android:layout_marginLeft="@dimen/bigGap"
android:layout_marginBottom="@dimen/bigGap"
android:layout_above="@+id/footer"
android:background="#006400"
> <!-- green background color -->
<RelativeLayout android:id="@+id/parentLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFD700"> <!-- yellow background color -->
<EditText android:id="@+id/postText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#dddddd"
android:inputType="textMultiLine"
android:gravity="top|left"
/> <!-- gray background color -->
<ImageView android:id="@+id/postImage"
android:layout_width="@dimen/thumbnailSize"
android:layout_height="@dimen/thumbnailSize"
android:visibility="gone"
android:layout_below="@id/postText"
/>
</RelativeLayout>
</ScrollView>
myEditText
の高さはであるため、全体は黄色の背景 ( の緑色の背景を完全に覆う) の上wrap_content
に灰色の背景 ( ) の 1 行で始まります。ただし、後ですべてのビューの背景を白に変更し (単一のコンポーネントのように見せるため)、ユーザーがその 1 行だけをタップしてキーボードをポップアップできるようにするのは直感に反します。 .EditText
RelativeLayout
ScrollView
EditText
私がしたいのは、 のクリックおよびロング クリック アクションを のクリックおよびロング クリック アクションにリダイレクトすることですRelativeLayout
がEditText
、以下のコードは機能しません。ヘルプ?
final EditText editText = (EditText) findViewById(R.id.postText);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.parentLinearLayout);
rl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Logger.d("onClick invoked!");
editText.performClick();
}
});
rl.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Logger.d("onLongClick invoked!");
return editText.performLongClick();
}
});
ここでの私の意図は、RelativeLayout
をクリックするとキーボードがポップアップし ( を実行した場合と同様EditText
)、長押しすると切り取り/コピー/貼り付け/テキスト選択オプションが表示されるようにすることです ( と同じ動作EditText
)。