Using Android studio 3.1, and I have a strange problem, I can't edit my UI,
I enter the content_main.xml, using the design tab, blueprint, anything i drag to the blueprint is not appearing, I use the infer constraints, still not helping
this is my XML code:
<?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/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="#layout/app_bar_main">
<EditText
android:id="#+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
tools:layout_editor_absoluteX="53dp"
tools:layout_editor_absoluteY="168dp" />
</android.support.constraint.ConstraintLayout>
I would't recommand using the UI designer, you don't get the feeling of what you are really doing with it. You should learn how to directly edit the XML file, this isn't really harder and at least you know what you are doing.
You must drag the widget to the component tree
ver imagen
Related
I'm designing a pretty complicated form on Android, and I'm using includes in my fragment. I basically have this:
include_form.xml
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:orientation="vertical"
tools:parentTag="android.widget.LinearLayout">
...
<Spinner
android:id="#+id/desired_time_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:prompt="#string/time_desired_field"
android:spinnerMode="dialog"
tools:listitem="#layout/item_spinner_simple" />
...
</merge>
which renders beautifully on Android Studio's preview. However, when including this on another file, like this:
fragment_signup.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
...
<include
layout="#layout/include_form"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
...
</LinearLayout>
This renders well on a device, or a simulator, but it's not rendered correctly on Android Studio's preview: it basically ignores the tools:listitem attribute on the Spinner.
This works flawlessly for other components, such as a RecyclerView. Does anyone have an idea, or have I stumbled upon a bug? Thanks!
** Edit 1 **
Tried to add tools:listitem="#layout/item_spinner_simple" to the include tag and that didn't work.
** Edit 2 **
It really does seem that this is a bug. I've created a bug report:
https://issuetracker.google.com/issues/132686264
I added a new android wear module based on this Google doc
but I am getting the error described in the title. Here is my layout.
<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.BoxInsetLayout 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="#color/dark_grey"
android:padding="#dimen/box_inset_layout_padding"
tools:context=".MainWearActivity"
tools:deviceIds="wear">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/inner_frame_layout_padding"
app:boxedEdges="all"> <---this is the offending line
<android.support.v7.widget.AppCompatTextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</FrameLayout>
</android.support.wear.widget.BoxInsetLayout>
Anyone know what's going on? I appreciate explanation as to why I am getting this error.
UPDATE: I removed the redundant android prefix. Android studio requires me to change the app prefix to change to android but even after doing so the error remains. Is it safe time to assume it is a bug?
Based on what Mike M suggested, I right clicked on the error and I selected suppress in Android studio. My Framelayout now looks like this. I do not however currently know what caused the warning.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/inner_frame_layout_padding"
app:boxedEdges="all"
tools:ignore="MissingPrefix">
This seems to work for now.
I searched a lot for this error but ended up seeing that everyone is suggesting of uninstalling android studio and reinstalling it with all sdk work which is not feasible to me. How can we remove this error in a decent way, please refer me to the answer if anyone has already given the right one.
Please use app instead of android.
app:layout_constraintWidth_percent="0.5"
Also, Add one constraint property like below:
app:layout_constraintStart_toStartOf="parent"
or
app:layout_constraintTop_toTopOf="parent"
your_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<Button
android:id="#+id/btn_temp"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintWidth_percent="0.5"
android:text="Hello World!"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
I'm using Intellij IDEA 2017.2.2 for Android app development. I have the following layout file:
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/image_x"
android:id="#+id/text_x"
android:layout_marginStart="24dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBaseline_toBaselineOf="#+id/edit_image_x" />
...
</android.support.constraint.ConstraintLayout>
However when I open Design tab, I see that value of layout_marginStart is ignored and there is 0 in properties panel. When I try to set margin to other value, editor does not set layout_marginStart to new value, but creates layout_marginLeft what has no effect because there is still layout_marginStart.
This problem appeared after upgrade of Intellij IDEA from 2016.3 to 2017.2.2.
Is it a bug? How can I fix it? I don't want to remove all layout_marginStart from my code and replace it with layout_marginLeft. Is there any other solution?
I am trying to build up android app layout and my problem is that one element has some weird padding/margin and I can't find where it's been given. I triple checked my code and I'm sure that elements in my XML layout have no specific margins or padding (images attached). Is there any way to figure out what is going on? I have turned on show element borders on my device and it wasn't very helpful. I'm a beginner in the Android world and I wonder is there any specific tool to help in this kind of situation? I would be grateful for any kind of advice. Thanks!
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="#+id/monthPageTitlePageIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:clipToPadding="false"
app:backgroundTintMode="multiply"
app:tabMode="scrollable"
app:tabSelectedTextColor="#color/white" />
<android.support.v4.view.ViewPager
android:id="#+id/historyViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AAAAAA" />
</LinearLayout>
The red line below shows the unwanted space:
The following shows the borders: