Sunday, March 25, 2018

Android Studio AdMob ile Banner Reklam Ekleme

Merhaba Arkadaşlar;

Android Studio üzerinden para kazanmak istiyorsanız, reklam eklemek iyi bir yol olabilir. Reklam Eklemek için adımlar aşağıdaki gibidir. Android Studio AdMob ile Geçiş Reklamı Eklemek için tıklayınız.
  • https://www.google.com.tr/admob/ sayfasına giriniz ve kaydolun butonuna tıklayarak kayıt işleminizi gerçekleştirin.(Daha önceden oluşturduğunuz AdSense hesabınız ile sorunsuz kullanım sağlanamadığından yeni bir mail adresi ile de başvurabilirsiniz.) 
  • Uygulamalar Sekmesinden Uygulama Ekleseçeneğinden projenizi kaydedin.
  • Uygulama kimliğinizi not edin. Bu kimliği, AdMob'da reklam yayınlamak için uygulamanızın kaynak koduna eklemeniz gerekecek.
  • Uygulamanızda reklam göstermek için reklam birimi oluşturun. Biz bu uygulama için Banner reklam biçimini seçecerek reklam birimizi oluşturuyoruz.
  • Dilerseniz talimatları e-posta ile kendinize gönderdikten sonra projemize geçebiliriz.
Android Manifest dosyamıza: application'un üzerine aşağıdaki kodu yazıyoruz.

1
 <uses-permission android:name="android.permission.INTERNET" />
 2   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

build.gradle(Module:app) kısmına  aşağıdaki kodu ekliyoruz.

1
compile 'com.google.android.gms:play-services-ads:12.0.0'

.xml dosyamızın reklamı eklemek isteğimiz kısmına aşağıdaki kodları ekliyoruz.

1
2
3
4
5
6
7
8
<com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="15"
        android:visibility="visible"
        app:adSize="BANNER"
        app:adUnitId="uygulama kimliğini yazınız" />

Linear Layout kullanıyorsanız: Linear Layout'un içerisine aşağıdaki kodlarıda tanımlayın:)

1
2
3
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"

.java dosyamıza aşağıdaki kodları ekliyoruz.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;


private AdView mAdView;

 MobileAds.initialize(this,
                    "uygulama kimliğini yazınız");

            mAdView = (AdView) findViewById(R.id.adView);
            AdRequest adRequest = new AdRequest.Builder().build();
            mAdView.loadAd(adRequest);

LinearLayout iken, parametrelerini; xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/res-auto" olarak güncelleyiniz. ekleyiniz. Yararlı olmasını diliyorum, bol kazançlar.

Ekran Görüntümüz:

Friday, March 23, 2018

Floating Action Button Ekleme

Selam Arkadaşlar,

Android Studio 'da proje geliştirirken bazen Image View , Text View veya ViewPager'lar üzerine buton eklemek isteriz. Bunu yapabilmek için ihtiyacımız olan ise Floating Action Button😉 Ben Text View üzerine Floating Action Button Ekleme işlemini örnekleyeceğim.


Öncelikle Gradle kısmına aşağıdaki kodları yazın ve Sync Now ' a basın.

1
2
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'

Daha sonra .xml dosyasının gerekli kısmına aşağıdaki kodda gerekli kısımları alın:)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/favplus"
        app:backgroundTint="#FFFFFF"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="24dp"
        android:layout_marginStart="24dp"
        android:clickable="true"
        app:fabSize="mini"/>

    <TextView
        android:id="@+id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bg3"
        android:padding="10dp"
        android:fontFamily="sans-serif"
        android:gravity="center"
        android:textAlignment="center"
        android:textColor="#000000"
        android:textStyle="italic" />
</RelativeLayout>

Tuesday, March 6, 2018

Android Layout Yüzdeleme

Merhaba Arkadaşlar,

Bugün Android Projelerinde olmazsa olmaz ekran tasarımının bir parçası olan ekranı yüzdeliklere ayırmayı anlatacağım. Aslında "layout_weight " kodunu kullanacağız. Layout'un hangi bölümünün  ne kadar ağırlıkta kalmasını istediğimizi belirliyoruz.

Android Studioda sayfa tasarımı yaparken bazen sayfaları belli dilimlere ayırmak, sayfa tasarımını daha kolay yapmamızı sağlayabilir. Android Studioda Sayfa tasarımı yaparken;

.xlm kısmındaki layout sayfamızı açarak gerekli olan araçları sayfamıza ekliyoruz.İlk örneğimiz vertical olarak hazırlanmıştır.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="100"
    tools:context="com.hande.umut.buttontiklama.MainActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="50"
        android:orientation="vertical">

        <TextView
            android:id="@+id/text1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#7AC5CD"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:text="Yüzde50"
            android:textAlignment="center"
            android:textColor="#000000"
            android:textStyle="italic" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="20"
        android:orientation="vertical">

        <TextView
            android:id="@+id/text2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#76EE00"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:text="Yüzde 20"
            android:textAlignment="center"
            android:textColor="#000000"
            android:textStyle="italic" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="30"
        android:orientation="vertical">


        <TextView
            android:id="@+id/text3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#8A2BE2"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:text="Yüzde 30"
            android:textAlignment="center"
            android:textColor="#000000"
            android:textStyle="italic" />
    </LinearLayout>
</LinearLayout>

Dikey olarak hazırlanmış örneğimizde aşağıdaki gibidir;





 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="100"
    tools:context="com.hande.umut.buttontiklama.MainActivity">


        <TextView
            android:id="@+id/text1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#7AC5CD"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:layout_weight="50"
            android:text="Yüzde50"
            android:textAlignment="center"
            android:textColor="#000000"
            android:textStyle="italic" />

        <TextView
            android:id="@+id/text2"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="#76EE00"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:layout_weight="20"
            android:text="Yüzde 20"
            android:textAlignment="center"
            android:textColor="#000000"
            android:textStyle="italic" />


        <TextView
            android:id="@+id/text3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="30"
            android:background="#8A2BE2"
            android:fontFamily="sans-serif"
            android:gravity="center"
            android:text="Yüzde 30"
            android:textAlignment="center"
            android:textColor="#000000"
            android:textStyle="italic" />

</LinearLayout>