我想在我的上面只添加一个底部和一个顶部边框Linearlayout.我试过这样做:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:bottom="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#000" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
但它在形状周围添加了边框..
请问你能帮帮我吗 ?
我正在制作一个图片库应用程序.我目前有一个带有文本视图的imageview.目前它只是半透明的.我想让它淡入,等待3秒,然后淡出90%.引起关注或加载新图片将使其重复循环.我已经阅读了十几页,并尝试了一些事情,没有成功.我得到的只是淡入淡出并立即淡出
可以通过执行以下操作在Android中添加过滤器,以便为字段添加3个字符串限制:
editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(3) });
Run Code Online (Sandbox Code Playgroud)
那么删除已设置的过滤器呢?我的问题是我将在场上切换3到4个字符的最大长度,具体取决于用户的选择.只运行上面的代码就像是会为GC生成很多额外的工作.
我当然可以添加几个与每个过滤器对应的实例变量,只需在需要时添加它们,然后我只有两个过滤器,对于这种情况很好.知道是否可以完全删除过滤器会很有趣.也许通过传递null?
我的xml文件:
<SurfaceView
android:id="@+id/surfaceView"
android:layout_marginTop="50dp"
android:layout_width="fill_parent"
android:layout_height="300dp" />
Run Code Online (Sandbox Code Playgroud)
我的setDisplay功能:
public void playVideo() {
MediaPlayer mp = new MediaPlayer();
SurfaceView sv = (SurfaceView) this.findViewById(R.id.surfaceView);
try {
mp.setDataSource("sdcard/test/a.3gp");
SurfaceHolder sh = sv.getHolder();
mp.setDisplay(sh);***----the exception occured here***
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
日志如下:
04-24 22:19:33.645: W/System.err(16106): java.lang.IllegalArgumentException: The surface has been released
04-24 22:19:33.645: W/System.err(16106): at android.media.MediaPlayer._setVideoSurface(Native Method)
04-24 22:19:33.645: W/System.err(16106): …Run Code Online (Sandbox Code Playgroud) 如何在可见部分显示多少行TextView?我使用的文字并没有完全放在TextView每个屏幕分辨率上.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/logs_text"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
String s = "very big text"
TextView logText = (TextView) view.findViewById(R.id.logs_text);
logText.setText(s);
Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序,它通过REST API与服务器交互.显然,我需要使用不同的URL来开发和发布版本.评论和取消评论代码是非常乏味和错误的.
处理这种情况的最佳方法是哪种?在gradle文件中使用不同的构建类型是可以自动化该过程的类型,但我不确定这是否是正确的方法.
构建类型的数量也有增加的可能性.测试,内部释放等
我想将从相机拍摄的图像压缩为png格式,使它们的尺寸更小,所以我使用这个代码:
compressedPictureFile = new File(imagePath);
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
FileOutputStream fOut = new FileOutputStream(compressedPictureFile);
boolean compressed = bitmap.compress(Bitmap.CompressFormat.PNG, 0, fOut);
fOut.flush();
fOut.close();
Run Code Online (Sandbox Code Playgroud)
问题是compressedPictureFile实际上比原始图像(从1 Mb到6Mb)更大
我错过了什么?这是减少图像大小的最佳方法吗?
谢谢
当我进入下一个活动时,我能够给出自下而上的动画,但现在当我按下时,我使用相同的代码从上到下动画制作动画,但它总是自下而上,所以我的问题是如何给动画我在Android设备上按下按钮时从上到下?
请在下面找到我的代码.
我使用它在从一个过渡Activity到另一个过程中使用它Intent.
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
Run Code Online (Sandbox Code Playgroud)
和xml是:slide_in_up.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="100%p" android:toYDelta="0%p"
android:duration="@android:integer/config_longAnimTime"/>
Run Code Online (Sandbox Code Playgroud)
和slide_out_up.xml是
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p" android:toYDelta="-100%p"
android:duration="@android:integer/config_longAnimTime"/>
Run Code Online (Sandbox Code Playgroud) 最近我一直在研究一个有应用程序的应用程序SeekBar.该SeekBar所以可以有时很难用它(你必须在你的手势非常精确的)是相当薄.有没有办法增加可触摸区域SeekBar?因此,我希望用户能够触摸上方或下方SeekBar移动拇指.我很感激您提供的任何帮助!
我有一个实现自定义对话框的android活动.应用程序运行正常,但对话框太小,我想显示一个更大的对话框.我怎么能实现这个?这是我的布局xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/view_more_borders">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginTop="4dp"
android:gravity="center_vertical">
<TextView
android:id="@+id/share_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Company Name:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/nice_blue"
android:typeface="sans" />
<TextView
android:id="@+id/textViewCompanyName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.80"
android:text=" "
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="4dp"
android:gravity="center_vertical">
<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Price per share:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/nice_blue" />
<TextView
android:id="@+id/textViewprice_pershare"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_alignBaseline="@+id/Yesterday"
android:layout_alignBottom="@+id/Yesterday"
android:layout_marginLeft="38dp"
android:fontFamily="sans-serif"
android:layout_toRightOf="@+id/company"
android:text=" "
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" …Run Code Online (Sandbox Code Playgroud) android ×10
textview ×2
compression ×1
customdialog ×1
fadein ×1
fadeout ×1
lines ×1
surfaceview ×1
touch ×1