2

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

enter image description here

Naruto
  • 1,710
  • 7
  • 28
  • 39

1 Answers1

1

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)

enter image description here

Community
  • 1
  • 1
Arun C
  • 9,035
  • 2
  • 28
  • 42
  • I know they are using transparent style, my question is how to create an activity which doesn't take the whole screen – Naruto Aug 19 '13 at 10:59
  • It is just a layout trick... just make sure that your your contents are aligned to bottom... – Arun C Aug 19 '13 at 11:01
  • Ok so I have added several buttons and stuff in a relative layout and set the background image of the relative layout. Now it is taking the whole screen? what should I do now? – Naruto Aug 19 '13 at 13:40
  • @Naruto Can you post your xml...? Android have different sized screens so it may be difficult to achieve.. so they wont promote this sort of views.. Post your xml please let me have a look on it.. – Arun C Aug 19 '13 at 15:50
  • Nope it is not transparent activity. It is just floating window which is initiated by `Service` through `WindowManager`. I'm 100% sure because the app in that screenshot is what I'm using daily and I've written a floating app which is visible above all activities of other apps. – johnkarka May 20 '15 at 13:07