Android的活动与透明的背景和行动吧?透明、背景、行动、Android

2023-09-12 21:57:38 作者:长发及腰记得蹲坑要撩i

我尝试建立一个弹出我的Andr​​oid应用程序。它应该是一个活动不使用整个屏幕,只是200dp右侧屏幕和其余应该是透明的黑色

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.

一个图片是什么样子/我想有:的http://我。 stack.imgur.com/6APy6.png

A Picture of what it looks like / what i want to have: https://m.xsw88.com/allimgs/daicuo/20230912/126.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>

风格的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 :)

推荐答案

转到Android清单文件&GT;搜索所需的活动 - &GT; 有这样的:

Go to Android manifest file-> search for the required activity-> include this:

<--android:theme="@android:style/Theme.Translucent"-->

在这样的活动代码:

<activity
           android:name=".Services"
           android:label="@string/title_activity_services"
           android:theme="@android:style/Theme.Translucent" >
</activity>