Android 高仿百度貼吧發帖頁面

來源:互聯網
上載者:User

標籤:

本次項目是做一個論壇,我仿照了一下百度貼吧的發帖效果,實現介面如下所示,將源碼發出來分享一下。

核心主要是實現兩個地方:

1、點擊輸入框之後,頁面浮動,將下面的上傳圖片布局給頂上來。

2、輸入文章內容部分需要全螢幕顯示;

針對這兩個部分,這裡分別交代一下:

1)為了實現點擊輸入框之後,頁面浮動,將下面的上傳圖片布局給頂上來。這裡將內容部分嵌套一個ScrollView滾動模組,這樣就可以被頂起。

2)為了達到全螢幕顯示文章內容。這裡需要將ScrollView中加入如下設定:

android:fillViewport="true"

使內部支援android:layout_height="match_parent"

由於這是項目中的一部分,沒有單獨做Demo了,這就不放出來了~核心源碼全部在下面。


       


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" >        <!-- 載入標題列 -->    <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:layout_alignParentBottom="true"    android:orientation="horizontal"><!-- 載入底部欄 -->    <include        layout="@drawable/publish_note_bottom_bar" /></LinearLayout>    <!-- 文章標題 -->    <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_bottom_bar"        android:layout_below="@id/et_note_title"><!-- 文章內容 --><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">    <!-- 回退 -->     <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" />     <!-- 發表主題 -->     <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"/>     <!-- 佔位 -->     <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=""/>     <!-- 發帖 -->     <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>


Android 高仿百度貼吧發帖頁面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.