Android Studio: View who is visible only in preview - java

I have a simple question. I'm making application in Android Studio and I have got a problem. My application is creating buttons using Java. I want see these buttons in Preview editor, because I want have easier posibility to editing layout. So I made the same buttons in XML, but here is the problem. When I build my app it is showing both buttons! I want see only the buttons creating by Java code and finally here is my question it is possible remove buttons created in XML? I was thinking about tools:.. but I didn't find any usefull tag. Someone have any idea?

You can use tools:visibility="visible" and android:visibility="gone" together, so they show in the preview, but they're gone when the app is running on a device/emulator.

As already mentioned, you use tools:visibility="visible" in combination with android:visibility="gone" to render any view in preview but not in the build.
Using removeView(someChildElement) on your layout will remove the element you don't want. AFAIK, the XML code will still be there in the APK, but it isn't there at all in the built APK.
I have no clue why you want to show them in preview and not in the finished result. If it is because you want to toggle them manually later, you don't need any XML code. You can also do:
someView.setVisibility(GONE)
And a quick reference:
Visible - the view is visible
Invisible - the view is invisible, but still takes up space
Gone - the view is invisible and takes up no space
You cannot remove the code from the XML file on build though.

Related

Why don't I get a similar layout of Android Studio as displayed?

I am sorry, this is a noob question but I can't help feel isolated.
I was following an online course on Android and when they displayed the IDE for the first time it looked like this:
Referance Image
On the contrary, my screenshot looks like this:
My screenshot
How do I make my Android studio display that phone and thereby preview my code?
You are on the blueprint view. Click on the layout button that is located on the left of the blue button in the center and under main activity tab
There can be the reason that either IDE still processing the layout to display or there can be error in the XML code. If no error still you can refresh by pulling the error bar from the bottom and click refresh.

How to create a navigation that open from bottom of screen?

I want to create some thing like drawer menu that open from bottom of screen.
some thing like blow image. Also I want to know is that any special name?
You can use BottomSheet library. It works on Android 2.1+
https://github.com/soarcn/BottomSheet
It's called a SlidingDrawer. It was on the SDK but got deprecated a while back.
That said, this thrid-party library should do the job just as good. I've used it in multiple projects.

Adding views to MuPDFReaderView

I am currently using the MuPDF library from here: http://www.mupdf.com/
I've successfully compiled the library and everything is working great, though I am at a loss on how to achieve the following.
I want to attach views, such as button views, textviews, webviews and imageviews to the MuPDFReaderView. But everytime I try to add the view I fail to get any visible results, I can not see the attached view anywhere and I'm sure it's being added because when I debug it, the code is successfully run.
The reason I want to do this is to overlay views on the PDF view which will then scale and move along with the PDF document.
I ofcourse realise there isn't any code in this question, but I can't really post the entire MuPDF source code here, so here's what I think is relevant in a pastebin:
http://pastebin.com/qJFNsvdV
So yeah, how and where would I attach views to the document so they scale and move with the document properly?
We have a similar feature in our Android customizable magazine app, using muPDF: we add views on top on the pdf view to display slide shows or videos inside a magazine page.
This app is open source and available on Github. It should be easy for you to review the code, and see how we implemented this feature.

Unable to scroll the scrollview in GUI Designer

In my Android application, I have a ScrollView. This view includes more than what screen can show. To see the rest, I need to scroll down. But, in android GUI Designer, I am unable to scrollDown the ScrollView, because I can't see any option to do that.
I found this answer but I can't find the Clipping option they have mentioned. So, how can I scroll in Android GUI designer and design the rest of my application? I am using Eclipse Juno.
That sounds like something that needs to be checked in the emulator or on a phone. The GUI designer is not meant to be interactive or the end-all-be-all. It's supposed to give you a general idea of what it's going to look like live.

XML files and the ActionBar

I am very new to android programming, migrating over from iOS and I am having a hard time.
So, I have set up a new application in Eclipse IDE with a fixed tab and swipe navigation. So it appears to have created a ActionBar. However, I need to change the content of each page rather than it just telling me which tab I clicked.
I have been searching for this for about, 30-45 mins now, and I cannot find anything which makes any sense!
How can I attach a new XML file to a view?
I think the code you are looking for is:
setContentView(R.layout.your_xml_file)
Make sure your xml file is in your res/layout folder in your project
As for your button listener, check this answer.

Categories