發表圖片, 彈出界面, 相似QQ發說說時候添加照片的界面(不太會說,見諒)

首先上個圖, 就一不了然了, 下圖左邊是本身效果, 右邊是QQ效果android

OK, 看到這裏應該明白我標題的意思了吧.哈哈.佈局

首先, 來個佈局(activity_select_pic.xml)ui

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal" >
    <LinearLayout
        android:id="@+id/pop_layout_select_pic"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="center_horizontal"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/text_take_photo"
            android:layout_width="fill_parent"
            android:layout_height="50.0dip"
            android:layout_marginLeft="10.0dip"
            android:layout_marginRight="10.0dip"
            android:gravity="center"
            android:orientation="horizontal"
            android:text="拍照"
            android:background="@drawable/shape_popup_top" //這裏, 須要講
            android:textColor="#ff006cff"
            android:textSize="18.0sp" />
        
        <View
            android:layout_width="fill_parent"
            android:layout_height="1.0dip"
            android:layout_marginLeft="10.0dip"
            android:layout_marginRight="10.0dip"
            android:background="@color/liuliu_border" />
        
        <TextView
            android:id="@+id/text_pick_photo"
            android:layout_width="fill_parent"
            android:layout_height="50.0dip"
            android:layout_marginLeft="10.0dip"
            android:layout_marginRight="10.0dip"
            android:gravity="center"
            android:background="@drawable/shape_popup_bottom"//這裏, 須要講
            android:orientation="horizontal"
            android:text="從相冊"
            android:textColor="#ff006cff"
            android:textSize="18.0sp" />
        <View
            android:layout_width="fill_parent"
            android:layout_height="1.0dip"
            android:layout_marginLeft="10.0dip"
            android:layout_marginRight="10.0dip"
            android:background="@color/liuliu_border" />
        <TextView
            android:id="@+id/text_cancle"
            android:layout_width="fill_parent"
            android:layout_height="50.0dip"
            android:layout_margin="10.0dip"
            android:background="@drawable/shape_popup"//這裏, 須要講
            android:gravity="center"
            android:orientation="horizontal"
            android:text="取消"
            android:textColor="#ff006cff"
            android:textSize="18.0sp"
            android:textStyle="bold" />
    </LinearLayout>
</RelativeLayout>

上面已經標註了3個地方須要講一下, 就是TextView上面的拍照, 選取, 取消的這個三個的背景spa

分別是下面三個在drawable-hdpi裏面的文件code

shape_popup_top.xml, 就是長方形的上邊的兩個角是圓潤的(左上角, 右上角)xml

 <?xml version="1.0" encoding="utf-8"?>
<layer-list
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <solid android:color="#ffffffff" />
            <!-- 左上角 右上角-->
            <corners android:topLeftRadius="4.0dip" android:topRightRadius="4.0dip" android:bottomLeftRadius="0.100000024dip" android:bottomRightRadius="0.100000024dip" />
        </shape>
    </item>
</layer-list>

shape_popup_bottom.xml, 就是長方形的下邊的兩個角是圓潤的(左下角, 右下角)ip

 <?xml version="1.0" encoding="utf-8"?>
<layer-list
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
        <!-- 白色-->
            <solid android:color="#ffffffff" />
            <!-- 左下角, 右下角-->
            <corners 
                android:topLeftRadius="0.100000024dip" 
                android:topRightRadius="0.100000024dip" 
                android:bottomLeftRadius="4.0dip" 
                android:bottomRightRadius="4.0dip" />
        </shape>
    </item>
</layer-list>

shape_popup.xmlutf-8

 <?xml version="1.0" encoding="utf-8"?>
<layer-list
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <solid android:color="#ffffffff" />
            <!--四個角都是圓的-->
            <corners android:radius="4.0dip" />
        </shape>
    </item>
</layer-list>

OK, 到這裏以後, 就完成了佈局. 可是還沒完, 還有調出方式, 咱們要放在下面, 並且要是透明的, 這個就要在manifest中去規定了animation

 <activity
            android:name="com.gdut.pet.ui.ActivitySelectPic"
            android:label="@string/personal_central" 
            android:theme="@style/DialogStyleBottom"
            >
<!--這個是在manifest中定義的一個activity, 規定了他的theme是DialogStyleBottom-->

上面這個這個是在manifest中定義的一個activity, 規定了他的theme是DialogStyleBottom,string

 DialogStyleBottom以下(在values文件夾下的styles.xml)

 <style name="AnimBottom" parent="@android:style/Animation">
        <item name="android:windowEnterAnimation">@anim/push_bottom_in</item>
        <item name="android:windowExitAnimation">@anim/push_bottom_out</item>
    </style>
    <style name="DialogStyleBottom" parent="android:Theme.Dialog">
        <item name="android:windowAnimationStyle">@style/AnimBottom</item>
        <item name="android:windowFrame">@null</item>
        <!-- 邊框 -->
        <item name="android:windowIsFloating">false</item>
        <!-- 是否浮如今activity之上 -->
        <item name="android:windowIsTranslucent">true</item>
        <!-- 半透明 -->
        <item name="android:windowNoTitle">true</item>
        <!-- 無標題 -->
        <item name="android:windowBackground">@android:color/transparent</item>
        <!-- 背景透明 -->
        <item name="android:backgroundDimEnabled">true</item>
        <!-- 模糊 -->
    </style>

上面的應該能看得明白了

OK, 還差最後一部了, 就是出來的方式, 這裏用到animation,

文件在anim文件夾下面

push_bottom_in.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑入式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
        android:duration="200"
        android:fromYDelta="100%p"
        android:toYDelta="0"        
     />      
</set>

push_bottom_out.xml

 <?xml version="1.0" encoding="utf-8"?>
<!-- 上下滑出式 -->
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <translate
        android:duration="200"
        android:fromYDelta="0"
        android:toYDelta="50%p" />
</set>

ok, 到這裏就完成了, 去調用吧

相關文章
相關標籤/搜索