저는 자식이있는 상대 레이아웃을가집니다 (3 개의 버튼과 edittext). 초기 레이아웃은 선형 레이아웃 인 상위 레이아웃의 맨 아래에 배치됩니다. 화면 상단 (상위 선형 레이아웃)에 배치 된 버튼 중 하나를 클릭하면이 작업을 수행 할 수 있습니다. 그러나 다른 버튼을 클릭 할 때 원래 위치, 즉 화면 하단에 다시 표시되기를 원합니다. 제발 도와주세요.부모의 하단에 상대 레이아웃 포지셔닝 선형 레이아웃
내가 화면의 상단에있는 상대 레이아웃 "post_layout을"위치 reply_button을 클릭에<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/msg_detail_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/TitleBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/backbutton" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:singleLine="true"
android:textSize="30sp" />
</LinearLayout>
<RelativeLayout
android:id="@+id/post_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_alignParentBottom="true"
android:visibility="gone" >
<ImageView
android:id="@+id/post_upd_frame1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/post_upd_frame" />
<EditText
android:id="@+id/update_edit_view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/post_upd_frame1"
android:layout_alignRight="@id/post_upd_frame1"
android:background="@android:color/transparent"
android:inputType="textMultiLine"
android:maxLines="5"
android:singleLine="false"
android:focusable="true"
android:padding="10dp"
android:visibility="gone">
</EditText>
<ImageButton
android:id="@+id/post_btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/post_upd_frame1"
android:layout_alignRight="@id/post_upd_frame1"
android:layout_margin="5dp"
android:layout_marginLeft="5dp"
android:background="@android:color/transparent"
android:src="@drawable/post_message" />
<ImageButton
android:id="@+id/post_picture_btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/post_upd_frame1"
android:layout_margin="5dp"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="@id/post_btn1"
android:background="@android:color/transparent"
android:src="@drawable/add_picture" />
<ImageButton
android:id="@+id/post_Cancel_btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/post_upd_frame1"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
android:layout_toLeftOf="@id/post_picture_btn1"
android:background="@android:color/transparent"
android:src="@drawable/cancel_message" />
<ImageView
android:id="@+id/post_update_spinner_view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/post_btn1"
android:layout_centerHorizontal="true"
android:src="@drawable/running_indicator"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/reply_action_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_above="@id/post_layout1"
android:orientation="horizontal">
<ImageButton
android:id="@+id/delete_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:background="@android:color/transparent"
android:paddingBottom="5dp"
android:src="@drawable/xml_delete_button_selector" />
<ImageButton
android:id="@+id/reply_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/delete_button"
android:background="@android:color/transparent"
android:paddingBottom="5dp"
android:src="@drawable/xml_reply_button_selector" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/sent_received"
android:layout_alignTop="@+id/reply_button"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_margin="10dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
<ImageView
android:id="@+id/sent_received"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/reply_button"
android:background="@android:color/transparent"
android:src="@drawable/received" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
는, 내가이 일을 할 수,하지만 post_cancel_button의 클릭에 내가 할 상대 레이아웃 "post_layout"을 원하는 다음은 XML이다 다시 화면 하단에 위치한다. 버튼에 대한
RelativeLayout.LayoutParams rparams = (RelativeLayout.LayoutParams) mPostLayout.getLayoutParams();
rparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
mPostLayout.setLayoutParams(rparams);
코드 :
mReplyButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
RelativeLayout.LayoutParams rparams = (RelativeLayout.LayoutParams) mPostLayout.getLayoutParams();
rparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
mPostLayout.setLayoutParams(rparams);
InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mUpdateEditView, InputMethodManager.SHOW_FORCED);
}
});
mMessageReplyCancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
RelativeLayout.LayoutParams rparams = (RelativeLayout.LayoutParams) mPostLayout.getLayoutParams();
rparams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
mPostLayout.setLayoutParams(rparams);
}
});
mPostLayout는 XML
에서 상대 나 위치로 원하는 레이아웃, post_layout의 이름은 여기에 내가 화면 상단에 배치를 밀어 사용하고있는 코드는
코드를 게시 할 수 있습니까? – Sripathi
@sripathi xml뿐만 아니라 코드도 게시했습니다 – Badrul
rparams.addRule (RelativeLayout.ALIGN_PARENT_BOTTOM); – Sripathi