android-view

Electricity meter-like view - Android

僤鯓⒐⒋嵵緔 提交于 2019-12-11 21:13:15
问题 I am trying to include a widget / view in my Android app that displays a number and when the number is incremented, the new number slides into view as if each digit was on a rolling dial. In the UK (at least), electricity meters work in this way. Examples would be: See app image of https://play.google.com/store/apps/details?id=ie.esb.app.android See screenshots of http://www.appszoom.com/android_applications/lifestyle/using-the-power-meter-in-tokyo_vvfi.html A Google image search for "android

FrameLayout z-order not behaving as expected on Gingerbread?

倖福魔咒の 提交于 2019-12-11 19:41:57
问题 I have a layout as follows: <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" > <View android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" > <!-- children --> </LinearLayout> </FrameLayout> The LinearLayout has no background and neither do any of its children. I can

Android is taking wrong layout on Inflating View

自古美人都是妖i 提交于 2019-12-11 19:35:24
问题 I have layouts inside 3 folders: layout layout-large layout-xlarge When I start root activity everything is fine and android is inflating view from layout-xlarge folder (I' m using Samsung tablet that belongs to xlarge device) When I start next activity android is for some reason takign xml file from layout folder. I already tried obvious things like checking dimensions inside xml files, setting support small, normal, large and xlarge screens inside my Manifest file. There is a interesting

How to create a Tab-like UI in Android?

泄露秘密 提交于 2019-12-11 19:32:45
问题 I'm trying to implement a Tab-like UI inside an activity. This is how I want it to be. There are 3 button which each is associated with a LinearLayout. When the user clicks on a button the current visible layout fades out and the one associated with the clicked button fades into view. How can this be done? Specially how to make the fading effect? 回答1: Better you go with tab widget if still you want to do manually you can do as follows: Create one Relative layout (root) create one linear

Sending text from fragment to custom view where I want to use canvas.drawText [duplicate]

浪子不回头ぞ 提交于 2019-12-11 18:27:04
问题 This question already has an answer here : Supplying text from fragment to custom TextView (1 answer) Closed 6 years ago . I am new to Android and want to pass some text from a fragment to a custom view. Inside the custom view I want to use canvas.drawText to position the string. The reason I want to use canvas.drawText is for consistency with the position of some graphics. What is the procedure for this? Just to clarify, my fragment has something like this: public class Fragment1 extends

How to access component from another view in android

怎甘沉沦 提交于 2019-12-11 15:29:42
问题 I have created a custom dialog and inside it i create a view page which both have different layout file. Method to show the dialog is in MainActivity. I inflate a layout to my adapter class where i populate the content. In this layout there is a button. My question is "How can i access the button from the layout that i inflate in my adapter class from my MainActivity. The reason I want to do this is because I want to dismiss the dialog when the button is clicked. Thanks. Here is the code of

Replacing fragments quickly causes a weird screenshot of the previous fragment to persist and brought forward

吃可爱长大的小学妹 提交于 2019-12-11 13:06:28
问题 I'm using a HomeActivity which replaces fragments dynamically and adds it to content frame layout dynamically as the user selected items from the drawer. On each fragment, it loads a feed from the network which it then renders. Here is the code I use for the switch - public void loadFragment(Fragment frag, String tag) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id

Change margins programmatically doesn't work as expected

房东的猫 提交于 2019-12-11 12:53:41
问题 I have a GUI where Initially margins of innerLayout are 0,10,0,100 and in my intention hideinfoarea() should remove the infoLayout and change the margins in 0, 10,0,10 and showInfoarea() should restore the initial margins and show infoLayout again. Unfortunately when I set these margins some Layout become not well shown, for example the title is too close to mainLayout, and a piece of image will be covered by infoLayout when I re-enable it. despite in my test with layout editor the margins

Android: getApplicationContext() won't work in View subclass

时光怂恿深爱的人放手 提交于 2019-12-11 12:33:02
问题 So i have made a class DrawView which extends View and i want to draw some graph in that class with the points i stored as int array i made this array like a sort of public variable with the help of How to declare global variables So when i want to get connected with MyApp in Activity and change my array, i simply use MyApp appState = ((MyApp)getApplicationContext()); but the problem is that this won't work when i call it in my DrawView.java class. Any ides how to solve this? 回答1: I really

Animating Margin by ValueAnimator vs ViewPropertyAnimator translationX

一世执手 提交于 2019-12-11 11:49:29
问题 I am a beginner in android animation. I have few views inside a RelativeLayout and i wish to change view position. What are the options i have and how they differ? I have tried following: view.animate() .translationX(toX) .setDuration(duration); and RelativeLayout.MarginLayoutParams params = (RelativeLayout.MarginLayoutParams) view.getLayoutParams(); ValueAnimator animator = ValueAnimator.ofInt(params.rightMargin, 100); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {