https://imgur.com/a/arLyGYR
The design tab for my Android Studio doesn't display even the starting Hello World or my project name, does anybody know how to make this display and update as I write my program ?
edit: I'm not sure how the code will help, the tutorial im following says that the design tab should look like this upon opening https://imgur.com/a/FRgc2G1 and update as I code. I think it's a problem with the settings of android studio because the only code i've changed is what they have told me to.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:background="#0d7429"
tools:context=".MainActivity"
tools:layout_editor_absoluteY="25dp">
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
android:text="#string/Hello_World_Text"
android:textColor="#android:color/white"
android:textSize="30sp"
app:fontFamily="cursive" />
</android.support.constraint.ConstraintLayout>
It is because you have an error in your xml.
Changing TextView to android.support.v7.widget.AppCompatTextView works if you want to use "app" name space prefix for app:fontFamily. However,you can also use android namespace prefix for fontFamily but it is only compatible with API version 16 and higher.
go to app/res/values/styles.xml
if it says:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
change it to
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
Related
My Flutter app uses Google Pay as a payment method. Following these guidelines, they provide XML buttons (which I have never dealt with).
How can I add one of these button to a flutter widget using dart?
There are different implementations for laying out content for Android versus Flutter.
The layout/googlepay_button.xml layout effectively describes the way the button appears, and drawable/googlepay_button_content.xml contains VectorDrawable file for the Google Pay button. flutter_svg should help you render the contents of the image.
To get this to work with Flutter, you would need to reproduce the xml layout as a Flutter widget tree.
Sample layout black/res/layout/googlepay_button.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="48sp"
android:background="#drawable/googlepay_button_no_shadow_background"
android:paddingTop="2sp"
android:contentDescription="#string/googlepay_button_content_description">
<LinearLayout
android:duplicateParentState="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:duplicateParentState="true"
android:src="#drawable/googlepay_button_content"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:duplicateParentState="true"
android:src="#drawable/googlepay_button_overlay"/>
</RelativeLayout>
It looks like SVG. Try to open all these XML files like SVG, and add it to assets folder in your project.
I want to drag and drop elements into the Design View but I just can't. I can't even see the attributes aside when click into the screen or the default TextView that says 'Hello World!'. I tried restarting Android Studio, rebuild the project, and I still have the problem.
The code below is from my file 'activity_main.xml'.
How did happened?
I just tried to add a 'GridLayout' into the screen design, but to use it I had to install a library to use that grid layout and since I did that, I can't use the design view anymore.
Even I get an 'IDE Fatal Error' (screenshot below).
error ide image:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Remove
implementation 'com.android.support.constraint:constraint-layout:+'
from your build.gradle (app)
Hopefully Solve this problem
Is it possible to modify the XML layout template in Android Studio so that the namespace and attributes appear on separate lines?
Generated by default template:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
Preferred:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
The default template (below) shows each attribute (not including the namespace) on separate lines, but these line breaks don't translate to the generated resource file.
The problem is that Android Studio isn't respecting line breaks in the XML templates.
Solution
Enable Keep line breaks in
Settings > Editor > Code Style > XML > Other (tab)
Add a line break before the namespace in the relevant (see Notes) code template(s) in
Settings > Editor > File and Code Templates > Other (tab)
Result
XML layouts will now generate the namespace and attributes on separate lines, like so:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
Notes
The relevant code templates are:
layoutResourceFile.xml
layoutResourceFile_vertical.xml
To ensure that Keep line breaks persists on subsequent runs of
Android Studio, make sure to modify the Project scheme rather than
the Default scheme.
In an xml layout file, the xmlns is already defined, but I get this error at compile time: No resource identifier found for attribute. Why is that? thanks
I'm following a Facebook dev tutorial on facebook site https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/ the layout file is as follows:
<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"
>
<com.facebook.widget.ProfilePictureView
android:id="#+id/profilepic"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
app:preset_size="large" app:is_cropped="true"
/>
</ScrollView>
I figured it out, have to replace /res-auto with res/com.facebook.samples.profilepicture
Your layout file looks correct. check that in your 'project.properties' file, the 'android.library.reference.1' value points to the correct location.
The res-auto is feature properly supported in API level 17. It must be applied for all layouts using custom attributes. It is automatically replaced on build time, by eclipse.
Ref Updated SDK Tools and ADT revision 17
The following simple layout shows full screen on an Android phone, but not on Google TV where it
it shows on only a part of the TV screen (top half and middle third) and there's some sort of wallpaper on the rest of it (just saying in case it's not that usual, documentation is rare as far as I could see).
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.orb.androidplayer.view.VideoSurfaceView
android:id="#+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
The problem isn't coming fom the video widget either, it's the
same if I remove it, add a TextView instead, try fill/match parent, etc...
Can anyone assist me with identifying the cause of the issue?
Try setting your application or activity theme to
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen"
Try add element min SDK in AndroidManifest.xml
Exp: <uses-sdk android:minSdkVersion="7" />
Remove the <supports-screens/> tag from the AndroidManifest.