Reputation: 29
im trying to build a Popup for my Android App. It should be a Activity which doesn't use the whole screen, just 200dp on the right side of the screen and the rest should be transparent black.
A Picture of what it looks like / what i want to have: https://i.sstatic.net/6APy6.png
Java:
public class ActivitySettings extends BaseActivity implements View.OnTouchListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
setFinishOnTouchOutside(true);
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
System.out.println("Klicked " + motionEvent.getAction());
// If we've received a touch notification that the user has touched
// outside the app, finish the activity.
if (MotionEvent.ACTION_OUTSIDE == motionEvent.getAction()) {
finish();
return true;
}
return false;
}
}
AndroidManifest:
<activity
android:name="com.cleverlize.substore.test.ActivitySettings"
android:label="@string/title_activity_settings"
android:theme="@style/Theme.Transparent">
</activity>
Style XML:
<style name="Theme.Transparent" parent="Theme.AppCompat.Light">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/itemPremium</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
So i just need the adjustment and the ActionBar... please Help :)
Upvotes: 0
Views: 3207
Reputation: 24
Go to Android manifest file-> search for the required activity->
include this:
<--android:theme="@android:style/Theme.Translucent"-->
in the activity tag like this:
<activity
android:name=".Services"
android:label="@string/title_activity_services"
android:theme="@android:style/Theme.Translucent" >
</activity>
Upvotes: 0
Reputation: 329
Suppose your Activity layout is inside the LinearLayout, set the inner layout margin from left 200sp:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="200sp"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Text Display"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Reputation: 4008
You can have acitivity without titlebar and actionbar in manifest with the theme as
<activity
android:name="com.demo.YourActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
and for layout
android:background="@android:color/transparent"
android:layout_alignParentRight="true"
Upvotes: 2