简体   繁体   中英

Creating custom looking android activity

I have seen certain apps in play store that doesn't take full screen like the normal activities do. They take a portion of screen. I have tried to search a solution but as I am newbie, I don't know the exact words that are used for such kind of activities. How can I create such activities? Regards

在此处输入图片说明

These are using Transparent Activity . You can kind how to create transparent activities here and here .

For example

You could apply a transparent theme to the required activity. Create a new style in /res/values/style.xml

<resources>
<style name="iosTransparent">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>
</resources>

Now Apply theme

<activity android:name="IosNotActivity" android:theme="@style/iosTransparent"></activity>

Make a layout like this (it is just a sample)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/opLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:gravity="bottom">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/ios" 
        android:scaleType="fitXY"/>

</LinearLayout>

Gives output like this(this is scaled since i used just an image, you can use any layout you want)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM