වෙනත් ක්රියාකාරකමක් මත විනිවිද පෙනෙන ක්රියාකාරකමක් නිර්මාණය කිරීමට මට අවශ්යය.
මට මෙය සාක්ෂාත් කරගත හැක්කේ කෙසේද?
වෙනත් ක්රියාකාරකමක් මත විනිවිද පෙනෙන ක්රියාකාරකමක් නිර්මාණය කිරීමට මට අවශ්යය.
මට මෙය සාක්ෂාත් කරගත හැක්කේ කෙසේද?
Answers:
ඔබගේ res/values/styles.xmlගොනුවේ පහත ශෛලිය එක් කරන්න (ඔබට එකක් නොමැති නම් එය සාදන්න.) මෙන්න සම්පූර්ණ ගොනුවක්:
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>
(වටිනාකම @color/transparentයනු #00000000මා res/values/color.xmlගොනුවේ දැමූ වර්ණ අගයයි . ඔබට @android:color/transparentපසුව ඇන්ඩ්රොයිඩ් අනුවාදවලද භාවිතා කළ හැකිය .)
ඉන්පසු ඔබේ ක්රියාකාරකමට ශෛලිය යොදන්න, උදාහරණයක් ලෙස:
<activity android:name=".SampleActivity" android:theme="@style/Theme.Transparent">
...
</activity>
<item name="android:windowBackground">@android:color/transparent</item>
                    android:windowIsFloating. සාමාන්ය ක්රියාකාරකමක් ලෙස හැසිරීමට මෙම දේපල ඉවත් කරන්න (මේ අවස්ථාවේ දී එය android:style/Theme.Translucent.NoTitleBar
                    AppCompatActivity. ඒ නිසා parent="android:Theme"මගේ යෙදුම නැවතුනේ විය. මම එය ඉවත් කළ අතර එය චාම් ලෙස ක්රියා කළෙමි. ස්තූතියි!
                    එය මෙසේ ය:
<activity android:name=".usual.activity.Declaration" android:theme="@android:style/Theme.Translucent.NoTitleBar" />50% black should be #7f000000. සෑම සංරචකයක්ම (A, R, G, B) සිට අගයන් ලබා ගත හැකිය 0-255. 50% of 255 = 127. 127 in Hex = 7Fවිනිවිදභාවය (පාරාන්ධතාව) ගණනය කරන්නේ කෙසේද
                    Style.xml හි:
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
    <item name="android:background">#33000000</item> <!-- Or any transparency or color you need -->
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>AndroidManifest.xml හි:
<activity
    android:name=".WhateverNameOfTheActivityIs"
    android:theme="@style/Theme.AppCompat.Translucent">
    ...
</activity>Theme.Appcompat.Light.NoActionBarඒ වෙනුවට උරුම කර ගැනීමට ඔබට අවශ්ය විය හැකිය .
                    backgroundකැමති අර්ධ පාරදෘශ්ය වර්ණය ඉවත් කර දැමීමට අවශ්යයිwindowBackground
                    ඔබේ ක්රියාකාරකම් මේ ආකාරයෙන් මැනිෆෙස්ටයේ ප්රකාශ කරන්න:
 <activity   
     android:name=".yourActivity"    
     android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>ඔබේ පිරිසැලසුමට විනිවිද පෙනෙන පසුබිමක් එක් කරන්න.
ඔබේ ව්යාපෘතියේ ඇන්ඩ්රොයිඩ් මැනිෆෙස්ට් ගොනුවේ විනිවිද පෙනෙන බවට පත් කිරීමට අවශ්ය ක්රියාකාරකම් සඳහා පාරභාසක තේමාව පවරන්න:
<activity
    android:name="YOUR COMPLETE ACTIVITY NAME WITH PACKAGE"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />මගේ නඩුවේදී, සමහර කොන්දේසි මත පදනම්ව මට ජාවා හි ධාවන වේලාව තේමාව සැකසිය යුතුය. එබැවින් මම එක් තේමාවක් ශෛලියෙන් නිර්මාණය කළෙමි (වෙනත් පිළිතුරු වලට සමාන):
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>ජාවාහිදී මම එය මගේ ක්රියාකාරකමට යොදන ලදි:
@Override
protected void onCreate(Bundle savedInstanceState) {
    String email = getIntent().getStringExtra(AppConstants.REGISTER_EMAIL_INTENT_KEY);
    if (email != null && !email.isEmpty()) {
        // We have the valid email ID, no need to take it from user,
        // prepare transparent activity just to perform bg tasks required for login
        setTheme(R.style.Theme_Transparent);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
    } else
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dummy);
}මෙහි එක් වැදගත් කරුණක් මතක තබා ගන්න : ඔබ setTheme()පෙර ශ්රිතය අමතන්න super.onCreate(savedInstanceState);. ධාවන වේලාවේදී මගේ තේමාව පිළිබිඹු නොවන්නේ මන්දැයි සිතමින් මම මෙම කරුණ මග හැරී පැය 2 ක් රැඳී සිටියෙමි.
මම නව ඇන්ඩ්රොයිඩ් සංවර්ධකයෙකු වන බැවින් මේ සඳහා ටිකක් එකතු කිරීමට මට අවශ්ය විය. පිළිගත් පිළිතුර විශිෂ්ටයි, නමුත් මම යම් කරදරයකට මුහුණ දුන්නා. Colors.xml ගොනුවට වර්ණය එකතු කරන්නේ කෙසේදැයි මට විශ්වාස නැත. එය කළ යුතු ආකාරය මෙන්න:
<?xml version="1.0" encoding="utf-8"?>
<resources>
     <color name="class_zero_background">#7f040000</color>
     <color name="transparent">#00000000</color>
</resources>මගේ මුල් color.xml ගොනුවේ මට "අදින්න" යන ටැගය තිබුණි:
<drawable name="class_zero_background">#7f040000</drawable>ඒ නිසා මම වර්ණය සඳහාද එසේ කළෙමි, නමුත් "@ color /" යොමුව XML හි "වර්ණය" ටැගය සෙවීම බව මට නොතේරුණි. වෙනත් ඕනෑම කෙනෙකුට උපකාර කිරීම සඳහා මෙය සඳහන් කළ යුතු යැයි මම සිතුවෙමි.
android:theme="@android:style/Theme.Translucent"මැනිෆෙස්ටයේ ක්රියාකාරකම් ටැගය එක් කිරීමෙන් මම එය 2.3.3 දින ලබා ගත්තා .
පහළ අනුවාද ගැන මම නොදනිමි ...
AppCompatActivityකරන්නේ නම් භාවිතා නොකරන්න .
                    තුළ onCreate කාර්යය, පහත setContentView , මෙම මාර්ගය එකතු කරන්න:
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));මා සොයාගෙන ඇති පහසුම ක්රමය නම් ක්රියාකාරකම් තේමාව AndroidManifest හි සැකසීමයි android:theme="@android:style/Theme.Holo.Dialog".
ඉන්පසු ක්රියාකාරක onCreate ක්රමයේදී අමතන්න getWindow().setBackgroundDrawable(new ColorDrawable(0));.
සංවාද ක්රියාකාරකම් සඳහා මම මෙය භාවිතා කරමි:
getWindow().getDecorView().setBackgroundResource(android.R.color.transparent);නමුත් ක්රියාකාරකම තුළ ඔබගේ ප්රධාන දර්ශනය අදෘශ්යමාන ලෙස සැකසිය යුතුය. එසේ නොමැතිනම් පසුබිම අදෘශ්යමාන වන අතර එහි ඇති සියලුම දර්ශන දැකගත හැකිය.
ඉහත පිළිතුරු වලට අමතරව:
android Oreo ආශ්රිත ක්රියාකාරිත්වය බිඳ වැටීම වළක්වා ගැනීමට
<style name="AppTheme.Transparent" parent="@style/Theme.AppCompat.Dialog">
    <item name="windowNoTitle">true</item>
    <item name="android:windowCloseOnTouchOutside">false</item>
</style>
<activity
     android:name="xActivity"
     android:theme="@style/AppTheme.Transparent" />මම කාරණා දෙකක් කළා, එය මගේ ක්රියාකාරකම් විනිවිද පෙනෙන බවට පත් කළා. ඒවා පහතින්.
මැනිෆෙස්ට් ගොනුවේ මම පහත දැක්වෙන කේතය ක්රියාකාරකම් ටැගයෙහි එක් කළෙමි .
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"මම එම ක්රියාකාරකම සඳහා ප්රධාන පිරිසැලසුමේ පසුබිම " # 80000000 " ලෙස සකසා ඇත්තෙමි . මෙන්
android:background="#80000000"එය මට හොඳින් වැඩ කරයි.
ඔබ භාවිතා කරන්නේ AppCompatActivityනම් මෙය ඇතුලත් කරන්නstyles.xml
<style name="TransparentCompat" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>දී manifestගොනුව ඔයාට මේ වගේ ක්රියාකාරකම් ටැගය මෙම තේමාව එකතු කල හැක
android:theme="@style/TransparentCompat"වැඩි විස්තර සඳහා මෙම ලිපිය කියවන්න
භාවිතා Theme.NoDisplayතවමත් වැඩ කරනු ඇත ... නමුත් පැරණි Android උපාංග මත පමණි. ඇන්ඩ්රොයිඩ් 6.0 සහ ඉහළ මත, කැඳවීමකින් තොරව Theme.NoDisplay භාවිතා finish()දී onCreate() (or, technically, before onResume())ඇත හානිවීමට ඔබගේ යෙදුම. මෙම හේතුව වන්නේ ඒ නිර්දේශ භාවිතා කිරීමයි Theme.Translucent.NoTitleBarමෙම පෙළෙන නොවන, කිසිදු සීමා . "
සටහන 1: අදින්න හැකි ෆෝල්ඩරයේ test.xml නිර්මාණය කර පහත කේතය පිටපත් කරන්න
   <?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <stroke android:width="2dp" />
    <gradient
        android:angle="90"
        android:endColor="#29000000"
        android:startColor="#29000000" />
    <corners
        android:bottomLeftRadius="7dp"
        android:bottomRightRadius="7dp"
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp" />
</shape>සටහන: කොන් සහ හැඩය ඔබේ අවශ්යතාවය අනුව වේ.
සටහන 2: xml සාදන්න:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/test"
        android:orientation="vertical" >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1.09"
            android:gravity="center"
         android:background="@drawable/transperent_shape"
            android:orientation="vertical" >
     </LinearLayout>
    </LinearLayout>එම පිළිතුරු සියල්ලම ව්යාකූල විය හැකිය, විනිවිද පෙනෙන ක්රියාකාරකම් සහ කිසිවක් UI ක්රියාකාරකම් අතර වෙනසක් ඇත.
මෙය භාවිතා කිරීම:
android:theme="@android:style/Theme.Translucent.NoTitleBar"
ක්රියාකාරකම් විනිවිද පෙනෙන නමුත් UI අවහිර කරනු ඇත.
මෙය භාවිතා කරනවාට වඩා කිසිවක් UI ක්රියාකාරකමක් ඔබට අවශ්ය නම්:
android:theme="@android:style/Theme.NoDisplay"