How to set background color of a View
You made your button transparent. The first byte is the alpha. Try v.setBackgroundColor(0xFF00FF00);
You made your button transparent. The first byte is the alpha. Try v.setBackgroundColor(0xFF00FF00);
Is there a way to store that sub-select as a pseudo-column in the table? A VIEW like has been advised is a perfectly valid solution. Go for it. But there is another way that fits your question even more closely. You can write a function that takes the table type as parameter to emulate a … Read more
Actually if you create func: create function p1() returns INTEGER DETERMINISTIC NO SQL return @p1; and view: create view h_parm as select * from sw_hardware_big where unit_id = p1() ; Then you can call a view with a parameter: select s.* from (select @p1:=12 p) parm , h_parm s; I hope it helps.
For anything below Honeycomb (API Level 11) you’ll have to use setLayoutParams(…). If you can limit your support to Honeycomb and up you can use the setX(…), setY(…), setLeft(…), setTop(…), etc.
I’m amazed by everyone else’s MUCH more complicated answers. XML You can very simply define the alpha in the color definition of the button (or any other view) in your xml: android:color=”#66FF0000″ // Partially transparent red In the above example, the color would be a partially transparent red. When defining the color of a view, … Read more
here is my solution: public static Bitmap getBitmapFromView(View view) { //Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),Bitmap.Config.ARGB_8888); //Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); //Get the view’s background Drawable bgDrawable =view.getBackground(); if (bgDrawable!=null) //has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else … Read more
It’s deprecated but it still works so you could just use it. But if you want to be completly correct, just for the completeness of it… You’d do something like following: int sdk = android.os.Build.VERSION.SDK_INT; if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { setBackgroundDrawable(); } else { setBackground(); } For this to work you need to set buildTarget api … Read more
Here is a little code to accomplish it: LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(30, 20, 30, 0); Button okButton=new Button(this); okButton.setText(“some text”); ll.addView(okButton, layoutParams);
API 11 added a setRotation() method to all views.
You can use RelativeLayout. Let’s say you wanted a 30×40 ImageView at position (50,60) inside your layout. Somewhere in your activity: // Some existing RelativeLayout from your layout xml RelativeLayout rl = (RelativeLayout) findViewById(R.id.my_relative_layout); ImageView iv = new ImageView(this); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(30, 40); params.leftMargin = 50; params.topMargin = 60; rl.addView(iv, params); More examples: … Read more