Android Studio 3.5.3 show Design view empty but build is Successful - android-studio

newbie in Android studio. Using Android Studio 3.5.3 to create app and the Build is Successful
I have the default MainActivity and activity_main.xml
Problem:
when I clicked on the activity_main.xml
- The Design view empty. Thus I can not drag UI like Plain text or others onto the Design activity Layout
Made changes in Style.xml
added the Base in below:
1) style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"
but this does not work.
Need your help to solve this problem.
Thanks

#MikeBottle, There might be a couple of things going on here. It could be because your activity doesn't have theme assigned.
Please check this:
Note: In the design view, when you click the eye icon, it will give you the options to show / hide the layout decorations. It includes the top and bottom status bars. Please check if that changes anything.
Also, make sure the activity has theme assigned.
For the reference, I also included the layout preview to demonstrate how it look when show layout decorations is not checked.

Related

Find the View and container Fargment information from Click event captures in profiler

I am profiling a new application I am working with. I can see the captured pink circle, I want to find out where the view is ,In which fragment and where the click listener is defined.
Here I can only see the activity information.
It's a big project.
If you are using the latest version of Android Studio, when hovering over the green bar near the top, there should be a tooltip showing the Activity and Fragment.
Regarding how to find out the View, have you tried Android Studio's Layout Inspector? I don't know a single-click way to locate the listener but it may be feasible once you locate the view.

Android Studio: Component is selected but Attributes editor says "No component selected"

TL;DR: Although I can edit component attributes directly in XML (sanity check — I'm sane) the Attributes inspector pane claims nothing is selected. I.e. "It doesn't work."
I added a CardView to the main layout. It does show up in the Component Tree and in the Design Editor. I select the CardView in the Component Tree pane, but the Attributes pane says "No component selected".
I'm using Android Studio 3.5.2 on MacOS 10.15.1. This happens with all three CardViews (see screenshot).
Clicking the Text tab shows the XML for all the components, including the (so-called) "non-selected" one. Direct edits I make on the CardView XML entity do have effect, and the app builds and runs correctly, with all three CardViews showing up and scrolling in the ScrollView. So this is probably not a gradle issue (thanks autocorrect, it's not a cradle problem either). It's more like the build process knows about the views, but not the edit process.
I re-created the project from scratch, with the same result.
I had the same problem today with a FloatingActionButton in Android Studio on macOS.
Restarting Android Studio was the solution for me.

Rendering Problem in Android Studio Layout Preview

I've looked at the suggested answers and none of them get the layout preview to render properly. I have tried changing the theme and lowering the API.
With "AppTheme" selected as the theme, the layout preview does not render elements properly and does not match the emulator. The error messages, .xml, emulator and layout preview are shown in the screenshot.
Please let me know what information is needed. I am new-ish to android studio.
// Edit
The solution given by Jadhu worked with my previous IDE version. However, I also wanted to see the Action Bar in the preview. I tried to use the solution listed in the Jadhu's link but it still did not show the Action Bar.
After updating the IDE, I no longer need to make any changes but the Action Bar still will not appear.
// Edit 2
Make the Action Bar appear by clicking the "Eye Symbol" drop-down on the upper-left corner of the preview and selecting Show Layout Decorations.
Go to your res/values/styles.xml and change the:
"style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar""
to
"style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar""
if it doesnt work, you may find the answer Here, please feel free to take a look.

I can't find the toolbar in the layout editor in Android Studio

I'm trying to do the Android Developer Tutorial.
They refer to the toolbar in the layout editor, in the tutorial picture it looks like this:
But this is what I see
.
The toolbar with the eye is missing. As you see, there is a "Toolbar"-Icon in the menu, but clicking it has no effect.
I'm using Android Studio 2.3 and followed the previous lessons of the tutorial as demanded. How can I activate this toolbar?
This is the link for building an Android UI.
Was having this exact issue. Spent an hour looking for a solution for this, and turns out it was really easy. Note that you will need android studio version > 2.2.
In the activity_main.xml, look for the component tree. Likely there is a Linear_Layout or Relative_Layout. Just right click and then click 'Convert to
Constraint Layout'. Done.
This is the result: image.
Hope this helps. Happy coding.
The tutorial was written before the split between activity_main.xml and content_main.xml. This split was made in Android Studio 1.4. activity_main.xml is the main file, which includes content_main.xml in the line:
<include layout="#layout/content_main" />
If you follow the tutorial exactly, it's having you open activity_main.xml, which doesn't have any of the real "stuff" in it. Since activity_main doesn't have the TextView that the tutorial is trying to get you to look at, you don't get the correct toolbar icons populating to do the next few steps.
Short story: In the section "Open the Layout Editor", under Step 1, you should open content_main.xml instead of the activity_main.xml that's indicated. Things should be smooth from there.
For more information about the difference between activity_main.xml and content_main.xml, see What is the role of content_main.xml in android studio 1.4?
You have to add the v7 appcompat support library in gradle. so you can add
android.support.v7.widget.Toolbar in xml layout.

Android action bar home button not including activity title

I am using the home button of the main Activity of my IM app to allow the user to change their availability status. My app is using ActionBarSherlock, which falls back to the native implementation where supported.
However, the size of the tappable area is inconsistent between Android releases:
On Android 4.2.0 and before (including the compatibility library), only the icon is tappable:
On Android 4.2.1+, icon and activity name are tappable:
How can I make the tappable area consistently include icon and activity title on all versions of Android?
I am using ActionBarCompat (and you should probably update, if you haven't already), so this may not behave exactly the same. I wanted the full title to be clickable for using the navigation drawer. For some reason, using a custom logo instead of the text makes the whole thing automatically clickable, where only the icon could be clicked before:
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.im_title);
I don't know if it's possible to trigger that change while still using text with the default icon, but the setDisplay... methods and flags may be a good place to start looking.

Resources