PacktPublishing / Android-Programming-for-Beginners-Third-Edition

Android Programming for Beginners - Third Edition, published by Packt
MIT License
56 stars 57 forks source link

Emulator does not load the design as it is in design view #2

Open bimarsh123 opened 1 year ago

bimarsh123 commented 1 year ago

I don't know whether or not the old version of the android studio has this problem or not but whenever I run my code my emulator does not load the design as it is in the design view of card_content. I am using android studio electric eel version. `<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="@dimen/card_margin">

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

    <androidx.cardview.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_margin="@dimen/card_margin"
        app:cardCornerRadius="@dimen/card_corner_radius"
        app:cardElevation="2dp"
        app:cardUseCompatPadding="true">
        <include layout="@layout/card_contents_1"/>
    </androidx.cardview.widget.CardView>
</LinearLayout>

` here is my code for main_activity just wanted to try by adding first card content page but it is also not loading on emulator.

dangaske0 commented 1 year ago

I am facing the problem

deskpil0t commented 8 months ago

download an older version of android studio. https://developer.android.com/studio/archive

I am removed build tools 34. Setting the emulator to Pixel 3a API 16. (and i might have had to install some extra files underneath build tools 33).

And i have to customize the gradle. (Just updated it to deal with the textSize attributes on p104

app/build.gradle

`plugins { id 'com.android.application' }

android { compileSdkVersion 29 buildToolsVersion "29.0.2"

defaultConfig {
    applicationId "com.example.xtc"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

} `