I keep getting errors such as error:atrribute paddingleft not found and failed linking file resources errors and a few other does anyone know the solution to my problem in my main.java class I have it set as setContentView(R.layout.activity_main);
<?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"
tools:context="com.example.issacrodriguez.robber.main">
<TextView
android:id="#+id/scoreLabel"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingLeft="50dp"
android:paddingleft="10dp"
android:text="Score : 300"
android:textSize="18sp" />
<FrameLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/StartLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tap To Start!"
android:textSize="30sp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="130dp" />
<ImageView
android:id="#+id/robber"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/robberr"
android:layout_gravity="center_vertical"/>
<ImageView
android:id="#+id/moneybag"
android:layout_width="50dp"
android:layout_height="40dp"
android:src="#drawable/moneybag" />
<ImageView
android:id="#+id/cop"
android:layout_width="60dp"
android:layout_height="24dp"
android:src="#drawable/cop"/>
</FrameLayout>
</LinearLayout>
In this case you are doing Wrong-:
<TextView
android:id="#+id/scoreLabel"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingLeft="50dp"
android:text="Score : 300"
android:textSize="18sp" />
We have only android:paddingLeft="50dp" in android not something like
android:paddingleft="10dp" remove this it will compile then.
Related
I am developing an activity that searches for users in my Firebase realtime DB and I am using a cradview as a layout to inflate:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:backgroundTint="#FFFFFF"
android:elevation="0dp"
android:layout_marginBottom="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.cardview.widget.CardView
android:id="#+id/crdProfileImage"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
app:cardBackgroundColor="#color/textC"
app:cardCornerRadius="30dp">
<ImageView
android:id="#+id/imgHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/user_default"
android:scaleType="centerCrop"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/txtUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="#color/black"
android:layout_marginTop="5dp"
android:fontFamily="sans-serif"
android:textStyle="bold"
android:layout_toEndOf="#+id/crdProfileImage"
android:layout_marginLeft="25dp"
android:textSize="25dp"/>
<TextView
android:id="#+id/txtBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:layout_alignStart="#+id/txtUsername"
android:layout_marginTop="35dp"
android:text="Hi, this is my biography."/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
However, I noticed that when the recyclerview outputs the items, the items appear with an outline:
I thought it was the elevation, so I set it to 0, both on the recyclerview and on the layout in the cardview, but the result didn't change. Would anyone know how to solve?
EDIT:
I tried to remove the margin bottom but it still shows the elevation:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:backgroundTint="#FFFFFF"
card_view:cardElevation="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.cardview.widget.CardView
android:id="#+id/crdProfileImage"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
app:cardElevation="0dp"
app:cardBackgroundColor="#color/textC"
app:cardCornerRadius="30dp">
<ImageView
android:id="#+id/imgHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/user_default"
android:scaleType="centerCrop"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/txtUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="#color/black"
android:layout_marginTop="5dp"
android:fontFamily="sans-serif"
android:textStyle="bold"
android:layout_toEndOf="#+id/crdProfileImage"
android:layout_marginLeft="25dp"
android:textSize="25dp"/>
<TextView
android:id="#+id/txtBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:layout_alignStart="#+id/txtUsername"
android:layout_marginTop="35dp"
android:text="Hi, this is my biography."/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
Use
card_view:cardElevation="0dp"
Instead of
android:elevation="0dp"
Add the following line of code to disable the outlineProvider:
android:outlineProvider="none"
in addition to the android:elevation being 0dp just remove the android:layout_marginBottom="20dp" from your <com.google.android.material.card.MaterialCardView /> and then add android:padding for your children view in it to make the spacing
I've been trying to work out what's wrong with code but, I'am clueless now, pretty much checked everything, i get this error when am trying to build the login page for my app. Sorry for any inconvenience, i'am pretty noob at this.
No resource identifier found for attribute 'layout_width' in package 'android'. (line 2)
As well as a different error from java to deploy the theme for the app:
<?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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:background="#color/uberPrimary"
>
<Refractored.Controls.CircleImageView
android:id="#+id/circleImageView1"
android:layout_height="200dp"
android:layout_width="180dp"
android:layout_centerInParent="true"
android:src="#drawable/centerimage"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:textSize="20sp"
android:layout_below="#+id/circleImageView1"
android:layout_alignParentBottom="true"
android:textColor="#color/uberwhite"
/>
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="0.4"
android:padding="10dp"
>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/emailText"
>
<EditText
android:layout_height="wrap_content"
android:layout_widht="match_parent"
android:hint="Email"
android:inputType="textEmailAddress"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/passwordText"
>
<EditText
android:layout_height="wrap_content"
android:layout_widht="match_parent"
android:hint="Password"
android:inputType="textPassword"
/>
</android.support.design.widget.TextInputLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/loginButton"
android:layout_height="45dp"
android:layout_width="300dp"
android:text="Login"
android:textColor="#color/uberwhite"
android:background="#drawable/uberroundbutton"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</LinearLayout>
change
<EditText
android:layout_height="wrap_content"
android:layout_widht="match_parent"
android:hint="Email"
android:inputType="textEmailAddress"
/>
to
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:hint="Email"
android:inputType="textEmailAddress"
/>
credit to #laalto
I am using Android Studio 3.0 to make an Android App.
But the issue I am facing is that the Layout editor/previewer is not working properly. It is sometimes not showing anything and at times it is showing a grey box with all the navigation buttons.
These are the screenshots
I am using the buildToolsVersion '26.0.2' and the support libraries version is 23.0.1
Any help would be really helpful.
EDIT: This is my XML Layout
<?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"
android:background="#000000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"/>
<ImageView
android:id="#+id/logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:background="#drawable/logo" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"
android:textSize="33dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="15dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
You had a couple of problem with structuring your UI. Here is a fix, also make sure that the #drawable/logo file is at the drawable folder
<?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:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="horizontal" />
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
android:background="#drawable/logo"
app:layout_constraintBottom_toTopOf="#+id/name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout" />
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#FFF"
android:textColor="#000"
android:textSize="33sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/logo" />
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="207dp"
android:background="#FFF"
android:textColor="#000"
android:textSize="33sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/name" />
Every layouts in project has include layout. I have designed well in iclude layout. But in main layout of include layout don't show same view. for example the buttons move to the right of screen. I did different screen designs for small, normal, large and xlarge. But that didn't solve problem.
activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="#+id/loginlayout"
android:layout_height="match_parent"
android:background="#drawable/login_arkaplan"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100"
android:layout_marginRight="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="20dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_weight="90"
android:orientation="vertical"
>
<include layout="#layout/login_inner_part" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="2"
android:layout_gravity="center"
>
<TextView
android:id="#+id/textViewForgetPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="#string/lostpass"
android:textColor="#color/colorOrange"
android:textStyle="bold" />
<TextView
android:id="#+id/textViewRegister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="#string/register"
android:textColor="#color/colorWhite"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
activity_login_inner_part.xml
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="20"
android:gravity="center"
android:background="#color/colorWhite"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="10"
android:gravity="center"
android:weightSum="3">
<ImageView
android:id="#+id/login_logo"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
app:srcCompat="#drawable/login_logo"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="vertical">
<EditText
android:id="#+id/login_username"
android:layout_width="185dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:backgroundTint="#color/colorGrey"
android:ems="10"
android:hint="Eposta"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="84dp"
tools:layout_editor_absoluteY="267dp" />
<EditText
android:id="#+id/login_userpass"
android:layout_width="185dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:backgroundTint="#color/colorGrey"
android:ems="10"
android:hint="#string/password"
android:inputType="textPassword"
tools:layout_editor_absoluteX="84dp"
tools:layout_editor_absoluteY="341dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="#+id/btn_login"
style="?android:attr/buttonStyleSmall"
android:layout_width="185dp"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="20dp"
android:background="#color/colorPrimary"
android:clickable="true"
android:focusable="true"
android:text="GÖNDER"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I don't know why this button move right of screen. I am doing this include layouts first time and I don't know reason of it. I can't solve it. Please help me.
Possible solution would be to use RelativeLayout to center the button with reference to it's parent instead of giving it a fixed left margin.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/btn_login"
style="?android:attr/buttonStyleSmall"
android:layout_width="185dp"
android:layout_height="wrap_content"
<!-- IMPORTANT -->
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#color/colorPrimary"
android:clickable="true"
android:focusable="true"
android:text="GÖNDER"
android:textColor="#android:color/white" />
</RelativeLayout >
I have a layout that is being displayed in two different layouts. First one is being displayed in a LinearLayout and it behaves as expected:
However, when this layout is part of a listview, the textview is not centered:
Here's the layout:
<?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="130dp"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:padding="5dp">
<com.parse.ParseImageView
android:id="#+id/iv"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"/>
<TextView
android:id="#+id/tv_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.5"
android:layout_marginLeft="10dp"
android:textAppearance="#android:style/TextAppearance.Holo.Medium"
android:ellipsize="end"
android:maxLines="3"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:orientation="horizontal"
android:paddingLeft="10dp">
<View
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#color/blue"
android:layout_gravity="center"
/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/gray"
android:layout_margin="7dp"
/>
<TextView
android:id="#+id/tv_source"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="#android:style/TextAppearance.Holo.Small"
android:gravity="center"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/gray"
android:layout_margin="7dp"
/>
<TextView
android:id="#+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="sans-serif-light"
android:textAppearance="#android:style/TextAppearance.Small"
android:gravity="center"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/gray"
android:layout_margin="7dp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_fire"
android:layout_gravity="center"/>
<TextView
android:id="#+id/tv_viewCount"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="sans-serif-light"
android:textAppearance="#android:style/TextAppearance.Small"
android:gravity="center"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="5dp"/>
</LinearLayout>
<ImageView
android:id="#+id/pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pin"/>
<TextView
android:id="#+id/comment_tv"
android:layout_width="0dp"
android:layout_height="0dp"
android:textColor="#color/white"
android:layout_alignTop="#+id/pin"
android:layout_alignBottom="#+id/pin"
android:layout_alignLeft="#id/pin"
android:layout_alignRight="#+id/pin"
android:gravity="center"
android:layout_marginBottom="10dp"/>
</RelativeLayout>
The textView that I am referring to is at the bottom with id comment_tv
What am I doing wrong?
Thanks
Your pin+text inside a relative layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_gravity="center_vertical" >
<ImageView
android:id="#+id/pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pin"/>
<TextView
android:id="#+id/comment_tv"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignTop="#id/pin"
android:gravity="center"
android:layout_marginTop="10dp" //set this higher if you need
android:layout_centerHorizontal="true" //if this text will be not in the center
//you can use the "layout_marginLeft" to put whatever you want
/>
</RelativeLayout>
This should but the text on the spot you want
I tried it with your image and this is my result with underlying code. Is this what you are looking for?
<?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:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/sample"
android:gravity="center"
android:text="12"
android:textSize="18sp" />
</LinearLayout>
And heres a snapshot of this code: