您好,登錄后才能下訂單哦!
怎么在Android中實現微信小窗口功能?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
首先我們先定義布局文件:
<?xml version="1.0" encoding="utf-8" ?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/idtatabHost" android:layout_width="300dp" android:layout_height="500dp" android:layout_gravity="center" android:layout_weight="1"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/wechat" android:scaleType="fitXY"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="假的 WeChat" android:textSize="20dp" android:textColor="#ffffffff"/> <Button android:id="@+id/send" android:onClick="send" android:text="點我一下 有驚喜(嚇) 。。。" android:textColor="#ffffffff" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"/> </RelativeLayout>
然后我再活動中照常設置監(jiān)聽事件等方法:
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void send(View source){ finish(); } }
最重要的部分:
在未見的 mainfest.xml 中設置 活的的樣式為對話框風格
具體如下:
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Material.Dialog" tools:targetApi="lollipop"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業(yè)資訊頻道,感謝您對億速云的支持。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。