🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / Android RMOS / dinamik background color change

1-) Android RMOS - dinamik background color change2

backgront_1.xml

 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<
item>
    <
shape>
        <
gradient
            
android:angle="225"
            
android:startColor="#e63946"
            
android:endColor="#f1faee"
            
/>
    </
shape>
</
item>
</
selector>

backgront_2.xml

 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<
item>
    <
shape>
        <
solid
            
android:color="#e63946"
            
/>
    </
shape>
</
item>
</
selector>

backgront_3.xml

 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<
item>
    <
shape>
        <
gradient
            
android:angle="315"
            
android:startColor="#1d3557"
            
android:endColor="#e63946"
            
/>
    </
shape>
</
item>
</
selector>

gradient_list.xml

 

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<
item
    
android:drawable="@drawable/background_1"
    
android:duration="1000"
    
/>
    <
item
        
android:drawable="@drawable/background_2"
        
android:duration="1000"
        
/>
    <
item
        
android:drawable="@drawable/background_3"
        
android:duration="1000"
        
/>
</
animation-list>

 

fragment.xml

 

<LinearLayout
    
android:id="@+id/lineartAnasayfa"
    
android:layout_width="match_parent"
    
android:layout_height="match_parent"
    
android:background="@drawable/gradient_list"
    
android:orientation="vertical">

 

KULLANIMI :

 

public  void  dinamikArkaplan(){
    
AnimationDrawable animationDrawable = (AnimationDrawable) linearAnasayfa.getBackground();
    
animationDrawable.setEnterFadeDuration(1000);
    
animationDrawable.setExitFadeDuration(1000);
    
animationDrawable.start();
}

 

 

kaynak : https://www.youtube.com/watch?v=4lEnLTqsnaw&ab_channel=PracticalCoding

 

 2022 Ocak 13 Perşembe
 343