I'm at the beginning of my development for my game and I have a basic question.
Is the layout necessary for displaying a view?
I have the method which allows me to make the toolbar disappear and set the view screen wide, but it seems a bit useless to do so.
Besides in the snake sample provided in the sdk, the views are merged without a layout.
So, which one is the best practice.
And if it's the layout-less solution, how to do for a unique view to display?
Thanks.
Well, I am as new as you are too, but as far as I have searched and learned online and with a few examples, all I can say is, NO. Game programming does not need any xml layouts. For developing a game, you need to first create a good basic framework. All the views, sprites, actions, audio, etc... is created at background.
This is a very nice tutorial to start with.
It depends on lots of things, but yes you don't need to create an XML layout. Pay attention to the word XML. You can create a custom class which extends SurfaceView and work in cooperate with Thread to do the update. So in this case you just need to set your Activity's Content View to this subclass of SurfaceView. But by using SurfaceView you have a raw of context which means you should do everything from stratch, e.g you should implement your own button.
Beside this it depends on the engine/framework you use too. But for SurfaceView/Canvas API the lines I mentioned above is valid.
Related
I want to create a crossword puzzle using android studio. the problem that I run into is I can't figure out a good way to draw the crossword puzzle the crossword
upon selecting a word from that shape. the user will access an interface that is designed specifically for that word. where to enter the answer
The problem I have is how to actually create that crossword shape, especially since I need it to be created dynamically afterwards based on the supplied data.
After 15 days of research all I can find are those possibilities:
Using Table layout with each cell representing a character. But this approach is not appropriate and not optimate and create many problems.
Using GridView with the unused cells set to be invisible. this is better but I think there is a better way than creating Grids only to set most of it to invisible.*
**I am sure there is a better way, but can't figure it out.
I know I have to give a code sample for what I have but I can't even do that till I know what approach I need to create this. If there is any suggestion to make my question clear that will be welcomed as well.
Neither. This calls for custom view for the word grid. While you can probably get it to work without one, it's going to look very amateurish, and you're going to be very hacky. Instead, you'll want a totally custom view doing its own keyboard input handling. Unless this is like a school project where looks and UX don't matter and you just need it done.
I've got a lot of experience with Java and C#, but I'm new to Android. I mainly use C# because I am enamored of the Control hierarchy. I love the plug-and-play of the ontology. I'm trying to understand the ontology in this new paradigm and I may have been given some false information.
With respect to Apps, that should be the largest component. Within the App, there may be several Activities. An activity can display a number of Fragments. AppWidgets appear to be a special case as they exist as a component of the App, but are shown on their own. And I was told that you can extend Buttons or ProgressBar to create your own components which again appear to be called Widgets.
As I said, I may have this completely wrong. Ideally I would like to create my own widgets which I can put on a Fragment, an AppWidget or an Activity; any of which I might compose into an App. All the online sources I've found only discuss Widget in the sense of an AppWidget? Was I given incorrect information? Can anyone clarify the ontology?
Thanks
"Widget" is a bit of an overloaded term. You will probably have better luck if you search for tutorials on "custom Views" instead. I'll include a brief rundown of various terms and what they mean at the bottom.
A custom View is pretty much anything that extends the View class (or any of its subclasses) and isn't part of the framework. Custom views can be used wherever typical Views are expected, e.g. in layout files or directly constructed in Java. One thing to note: only certain Views can be used in an AppWidget because they are running in another process outside of your app. This means your custom Views cannot be used in AppWidgets. In my experience this tends not to matter too much.
App: An application. Contains components, which are defined in the manifest within the <application> tag.
Activity: One of the four application components. Nearly always has an associated UI, composed of a hierarchy of Views.
Fragment: A framework class that helps modularize your application's code and UI. Fragments can be attached to an Activity and can contribute some UI to the View hierarchy of the Activity. They are entirely optional; you don't have to use Fragments in your app, and you can attach a Fragment without it contributing any UI to the Activity.
View: A UI component, such as text (TextView) or images (ImageView). These are also referred to as "widgets", and you may notice the framework classes are found in the android.widget package. Some views contain other views, so that you can build a UI hierarchy; these will extend ViewGroup and are referred to as "view groups" or "layouts" more or less interchangeably.
AppWidget: Something the user can add to his or her homescreen. This is provided by the app, but is not one of the 4 application components mentioned previously (it is managed by an application component, namely a special subclass of BroadcastReceiver). Most people colloquially refer to these as "widgets" because it's shorter to say and launchers used that terminology as well, thus conditioning users to it.
Good Day everyone.I have searched internet and hardly found that it can't be like that but i really can't believe.So i decided to ask here whether is it possible to inflate layout which will have its own activity i mean JAVA CLASS where i would type the code.So just for this case.Imagine we must have google maps on screen and as well as separate screen of list view people all nearby.So in that point we want to inflate the layout onto google maps view.But as i can logically think it will be horrible to write code all in one class by side of performance,so I'm looking for alternatives to inflating a layout,is somehow we can bring activity on main screen and don't lose that screen as well?This is all questions.Thank you very much beforehand!
If I have understood you right, you want to have two layouts in one Activity?
You should use Fragments for it purpose. You can add as many as you want in one Activity, and manage them dynamically. You can find solution here. Also, look at this solution.
I am new to Android programming, and I need some advice. I want to create an app that teaches children the alphabet and numbers. I want each letter to have their own screen which you can scroll to and from other letters, but each screen will be similar in that it will have the current letter, pictures of objects that start with that letter, and sounds corresponding with the letter and the objects in the background. Should I make one XML layout for these and somehow changed what letter and objects show up in on the layout using Java, make an XML layout per letter, or is there a way to create a base layout in Java and have all of the letters and numbers inherit these qualities and methods. If that is the case, would that require a Java class per letter as well? I am sorry if these seem like stupid questions, but most of my education in Android has come from internet video tutorials. I appreciate any and all help. Thank you for your help in advance!
v> I want each letter to have their own screen which you can scroll to and from other letters, but each screen will be similar
You probably want to check out ViewPager and Fragments for this.
This website usually seems to have pretty good tutorials. The docs and SO usually have good examples of getting started also.
Note These both require API >= 11 or using a compatibility package which you can find a tutorial Here. so that may be something to take into consideration. If that is an issue then you could simply have one layout with TextView, ImageView, etc... which retrieves its data from a DB and load them when a certain event happens such as a click.
Well, if you want a screen for each of the letters that you could swipe to, but each letter is going to have its own set of properties, I recommend you start looking for a ViewPager with custom Fragments. I think that is a good start. Then, you could focus on some other fancy features like sound.
I want to create an activity, which shows a question with 4 answers, and at the bottom of the screen i want to place a timer.
I have already found timer example, and i created a question with the answers. the problem that they are 2 different projects and activities, and i am looking for the best way to implement it. i think i can't show 2 activities on one screen, but i can show 2 views or shell i use the ViewGroup, or maybe to copy-paste one of the activities code to another ( its the easiest way but probably the most ugliest way to implement it).
please tell me what is the best way, that i will study and not to waste time to study all the ways and only then to choose one of them.
welcome to StackOverflow.
You are correct in that you cannot display two activities at once. You must instead look into how layouts work in Android by reading some tutorials on the Android developer guide.
For your layout, I would recommend using a LinearLayout with four TextView objects inside it containing the questions (and perhaps your EditText objects below them) as well as your timer. Make sure they are all inside a ScrollView so the software keyboard doesn't force it all to be squeezed up. This is how I would approach it, but I encourage you to read about how layouts work and use the XML resources.
The Notepad tutorial is an excellent way to get started with views and text entry, as well as using SQLite databases.