Android high imitation Baidu Post Bar posting page, android high imitation
This project is a forum. I have modeled the posting Effect of Baidu post bar. The implementation interface is as follows. I will share the source code.
The core is to achieve two things:
1. After clicking the input box, the page floats and the following upload images are displayed on the top.
2. Enter the post content to be displayed in full screen;
Here we will explain the two parts separately:
1) in order to achieve the floating page after clicking the input box, layout the following upload image to the top. Here, a ScrollView scroll module is nested in the content part, so that it can be pushed up.
2) in order to display the post content in full screen. Add the following settings to ScrollView:
Android: fillViewport = "true"
Enable internal support for android: layout_height = "match_parent"
Because this is part of the project and there is no separate Demo, this will not be released ~ The core source code is all below.
Publish_note.xml
<? Xml version = "1.0" encoding = "UTF-8"?> <RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent"> <! -- Load the title bar --> <include android: id = "@ + id/publish_title_bar" layout = "@ drawable/publish_title_bar"/> <LinearLayout android: id = "@ + id/publish_note_bottom_bar" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: Expiration = "true" android: orientation = "horizontal"> <! -- Load the Bottom Bar --> <include layout = "@ drawable/publish_note_bottom_bar"/> </LinearLayout> <! -- Post title --> <EditText android: id = "@ + id/et_note_title" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_below = "@ id/publish_title_bar" android: hint = "@ string/tip_note_title"/> <ScrollView android: id = "@ + id/sv_note_contain" android: layout_width = "match_parent" android: layout_height = "match_parent" android: fillViewport = "true" android: layout_above = "@ id/publish_note_bot Tom_bar "android: layout_below =" @ id/et_note_title "> <! -- Post content --> <EditText android: id = "@ + id/et_note_contain" android: layout_width = "match_parent" android: layout_height = "match_parent" android: gravity = "top" android: inputType = "textMultiLine" android: singleLine = "false" android: hint = ""/> </ScrollView> </RelativeLayout>
Publish_title_bar.xml
<? Xml version = "1.0" encoding = "UTF-8"?> <RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: orientation = "horizontal" android: layout_width = "fill_parent" android: layout_height = "48dp" android: background = "@ color/index_title"> <! -- Rollback --> <ImageView android: id = "@ + id/im_back" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_centerVertical = "true" android: layout_alignParentLeft = "true" android: contentDescription = "@ string/desc_indexpic" android: src = "@ drawable/browser_back"/> <! -- Publish a topic --> <TextView android: id = "@ + id/TV _publish" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_centerInParent = "true" android: text = "@ string/publish_topic" android: textColor = "@ color/black" android: textSize = "18pt"/> <! -- Placeholder --> <TextView android: id = "@ + id/TV _null" android: layout_width = "10dp" android: layout_height = "wrap_content" android: layout_alignParentRight = "true" android: layout_centerVertical = "true" android: text = ""/> <! -- Post --> <TextView android: id = "@ + id/TV _publish_note" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_toLeftOf = "@ id/TV _null" android: layout_centerVertical = "true" android: textColor = "@ color/black" android: textSize = "18pt" android: text = "@ string/publish_note"/> </RelativeLayout>
Publish_bottom_bar.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <ImageView android:id="@+id/im_pictrue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:contentDescription="@string/desc_indexpic" android:src="@drawable/btn_pb_add_n" /></LinearLayout>