It is knowed that the StatusBar is black default of Andriod 4.2.
However,I want to make the StatusBar transparent on Launcher and change to be black when it come into an activity. And then,when it come back to the Launcher,the StatusBar recover to transparent.
There is a way to implement,but it do not work perfectly(the Activity open firstly and the StatusBar turn transparent slowly,No strict synchronization).
set "status_bar_background" to be #00000000;
delete the code "mStatusBarWindow.setBackground(null);" which in method "makeStatusBarView()" of PhoneStatusBar.java;
Edit mPixelFormat = PixelFormat.OPAQUE to mPixelFormat = PixelFormat.TRANSLUCENT;
change the code in WindowStateAnimator.java
updateSurfaceWindowCrop(), after the code line
"applyDecorRect(mService.mSystemDecorRect);"
Added:
if(w.mAttrs.type == LayoutParams.TYPE_WALLPAPER) {
w.mSystemDecorRect.top = 0;
}
I think cannot change StatusBar. If you want change, you has to change SystemUI
. You can references via link: http://forum.xda-developers.com/showthread.php?t=2366476
Hide the status bar and use you own header instead of it, best Solution.
Related
I have opened an image with this code:
this.imp = IJ.openImage(imageFilePath);
imp.show();
And now, I need to set the scaleBar. I need to set it after imp.show() because the user has to draw a line before (and later set the scale).
But it only works before imp.show(). Can I put it after show or something similar? Do I need to invoke a refresh or update method?
So I got following problem:
I'm currently developing a sensor app and I'd like to check if the sensors are available or not. If they aren't, I want to change the color of a button (which starts an activity where the value of the sensor is being displayed) to grey.
Sadly, I can't just change the background color of the button because I'm using the Circle Button Library by Markushi.
This button looks like this:
<at.markushi.ui.CircleButton
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/gyroscope"
app:cb_color="#color/colorMain"
app:cb_pressedRingWidth="8dip"
android:id="#+id/gyroscope"
android:layout_alignLeft="#+id/temperature"
android:layout_alignStart="#+id/temperature"
android:layout_below="#+id/title"/>
As you can see this attribute defines the color.
app:cb_color="#color/colorMain"
My Question is: How can I change this color programmaticly in this method?
public void testSensors() {
if (testManager.getDefaultSensor(Sensor.TYPE_TEMPERATURE) == null) {
}
}
EDIT:
setColor doesn't really work. There is this border left. (see image)
Also: I'm using #616161 as the new color.
EDIT2:
Found out, that the border is caused by the transparent circle thing which gets bigger, when the button is pressed. So basically removing this circle thing will be fine. I try to find an answer on my own :)
CircleButton button;
button = (Button)findViewById(R.id.buttonId);
public void testSensors() {
if (testManager.getDefaultSensor(Sensor.TYPE_TEMPERATURE) == null) {
button.setColor(Color.parse("#000000"));
}
}
If you are using normal button then
button.setBackgroundColor(ContextCompat.getColor(context,R.color.colorAccent));
You can use
1) Color.parse("#000000")
2) ContextCompat.getColor(context,R.color.yourColor)
You can use the setColor() method of the circleButton, as you can see from the source code here .
So basically what you need to do is get a reference to your circle Button, using the findViewById method of your activity. then
public void testSensors() {
if (testManager.getDefaultSensor(Sensor.TYPE_TEMPERATURE) == null) {
myCircleButton.setColor(Color.parse("#000000"));
}
}
Also if you are seeing the pressed ring, then that means the state of the button is somehow in the pressed state, so try setting it o false using the setPressed(false) method.
To answer this problem (if anyone has the same):
You can set the animation to 100. This somehow disables the circle.
For some reason the color of the button has now a fixed color (dark grey) but scince this is fine to me and I don't want to cry under my table, I just let it be and move on with my project.
mCircleButton.setAnimationProgress(100);
Thank you all so much for your help! :)
I'm trying to resize an existing PDF button. I want to amend the label from "Print" to "Print Amended".
PushbuttonField button = form.getNewPushbuttonFromField("HoldButton");
Rectangle box = button.getBox();
box.setRight(box.getRight() + 72); // Increase width by 1"
button.setBox(box);
button.setText("Print Amended");
form.replacePushbuttonField("HoldButton", button.getField());
The above code successfully changes the label, but not the size. The end result is a button with no change in width, and the label "Print Amended" squished together.
Is it possible to resize an existing button in iText?
I tried your example and I was surprised that I could reproduce your problem.
I looked into the iText code and I see that it is explicitly forbidden to change the /T value. This makes sense: if you want to replace an existing button, you don't want to change its name.
However, for some reason we also explicitly forbid changing the /Rect value. See the code of the AcroFields class:
for (Object element : button.getKeys()) {
PdfName key = (PdfName)element;
if (key.equals(PdfName.T) || key.equals(PdfName.RECT))
continue;
if (key.equals(PdfName.FF))
values.put(key, button.get(key));
else
widgets.put(key, button.get(key));
merged.put(key, button.get(key));
markUsed(values);
markUsed(widgets);
}
I am not sure why we made this decision when we wrote this code. If I remove || key.equals(PdfName.RECT), then your code works as expected.
As we deliberately excluded changing the dimensions of the button, I am in doubt if this is a bug or if we intentionally added that code there. Reading your requirement, I am inclined to remove || key.equals(PdfName.RECT) from the official source code.
PS: I know that this doesn't answer your question, but it does explain why your code doesn't work in spite of the fact that it looks perfectly OK. As I explained: I'm really surprised that it doesn't work, because I'm responsible for the iText code...
PS 2: I've changed the code in the official trunk.
Try something like:
newButton1 = new JButton("Print Amended") {
{
setSize(150, 75);
setMaximumSize(getSize());
}
};
or:
Try to use setMaximumSize() method
button.setMaximumSize(new Dimension(100,100));
I'm using a Service that displays a view using WindowManager, and animation occurs every time I change the view's size using
windowManagerLayoutParams.height = newHeight;
((WindowManager) getSystemService(WINDOW_SERVICE)).updateViewLayout(mMainLayout, windowManagerLayoutParams);
If I disable manually the scale animations, no animation occurs.
Scale animation disabled manually like so:
http://www.cultofandroid.com/11143/android-4-0-tip-how-to-find-and-disable-animations-for-a-snappier-experience/
Is there a way to disable the window scale animations for my application programmatically?
I just had this same problem while working on a system overlay in the SystemUI package and decided to dig through the source to see if I could find a solution. WindowManager.LayoutParams has some hidden goodies that can solve this problem. The trick is to use the privateFlags member of WindowManager.LayoutParams like so:
windowManagerLayoutParams.privateFlags |= 0x00000040;
If you look at line 1019 of WindowManager.java you'll see that 0x00000040 is the value for PRIVATE_FLAG_NO_MOVE_ANIMATION. For me this did stop window animations from occurring on my view when I change the size via updateViewLayout()
I had the advantage of working on a system package so I am able to access privateFlags directly in my code but you are going to need to use reflection if you want to access this field.
As #clark stated this can be changed using reflection:
private void disableAnimations() {
try {
int currentFlags = (Integer) mLayoutParams.getClass().getField("privateFlags").get(mLayoutParams);
mLayoutParams.getClass().getField("privateFlags").set(mLayoutParams, currentFlags|0x00000040);
} catch (Exception e) {
//do nothing. Probably using other version of android
}
}
Did you try Activity#overridePendingTransition(0, 0)?
Check out the documentation:
Call immediately after one of the flavors of startActivity(Intent) or finish() to specify an explicit transition animation to perform next.
I'm making minesweeper for a school project. When the player wins or loses, the mines are revealed. Their buttons are disabled, and icons of flags/mines will appear. The problem is that the icons turn grey when the buttons are disabled. Is there a way around this?
I have also tried setting the text of the JButton to something like "<html><img src=\"res\\mine.png\"/></html>" but it showed some weird image.
Update:
I tried using setDisabledIcon() but nothing's showing up. Here's some pseudo-code
The buttons I use for the minefield is a class called Field, which extends JButton
mouseReleased(mouseEvent e) {
Field fieldClicked = (Field)e.getSource();
if fieldClicked is mine {
fieldClicked.setEnabled(false);
gameTimer.stop();
setLost(true);
loop through 2D array of fields {
if field is a mine {
field.setDisabledIcon(Field.mineIcon);// public static final icon of Field. mineIcon = new ImageIcon("res\\mine.png")
field.setEnabled(false);
}
}
}
}
Figured this out in a test
For some reason
clickedButton.setDisabledIcon(mineIcon)
Alone doesn't do anything.
But:
clickedButton.setIcon(mineIcon)
clickedButton.setDisabledIcon(mineIcon)
Will show whatever icon I wanted
a JButton actually allows seven associated images: the main image (use
setIcon to specify it if not supplied in the constructor), the image
to use when the button is pressed (setPressedIcon), the image to use
when the mouse is over it (setRolloverIcon, but you need to call
setRolloverEnabled(true) first), the image to use when the button is
selected and enabled (setSelectedIcon), the image to use when the
button is disabled (setDisabledIcon), the image to use when it is
selected but disabled (setDisabledSelectedIcon), and the image to use
when the mouse is over it while it is selected
(setRolloverSelectedIcon).
- http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JButton.html
so use setDisabledIcon(ImageIcon)
The greyed image is the automatically generated one, in case you want a different icon, use setDisabledIcon()
Icon disabledIcon = new ImageIcon("youricon.gif");
button.setDisabledIcon(disabledIcon);