我正在尝试使用 ViewPager 和 Volley 的 NetworkImageView 制作图像库。viewpager 和图像检索一切正常。但是当我将位图放入 NetworkImageView 中时,图像不会拉伸以填充 NetworkImageView 的大小。对于我的其他 ImageView,设置scaleType 效果很好。
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY" />
Run Code Online (Sandbox Code Playgroud)
我的 xml 文件
public static class SwipeFragment extends Fragment {
ImageLoader imageLoader = AppController.getInstance().getImageLoader();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View swipeView = inflater.inflate(R.layout.swipe_fragment, container, false);
NetworkImageView imageView = (NetworkImageView) swipeView.findViewById(R.id.imageView);
Bundle bundle = getArguments();
int position = bundle.getInt("position");
if (imageLoader == null) {
imageLoader = AppController.getInstance().getImageLoader();
}
imageView.setImageUrl(fotoUrl.get(position), imageLoader);
return swipeView;
}
static SwipeFragment newInstance(int …Run Code Online (Sandbox Code Playgroud) 我试图在fab的其他项目中实现浮动操作按钮并自定义它,它工作正常.但这次,当我在xml布局中创建fab对象时,它显示错误.感到困惑,它试图删除它的一些标签,并发现给出android:backgroundTint标签是错误出现的时候.
这是代码:
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="mini"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_action_fab"
android:backgroundTint="#2196F3"
android:layout_margin="12dp"/>
Run Code Online (Sandbox Code Playgroud)
这是我的构建:
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.xxxx.xxxx"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "2.0.4"
}
Run Code Online (Sandbox Code Playgroud)
我还添加了谷歌设计gradle.
错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxxx.xxxx/com.xxxx.xxxx.HomeActivity}: android.view.InflateException: Binary XML file line #141: Binary XML file line #141: Error inflating class android.support.design.widget.FloatingActionButton
Run Code Online (Sandbox Code Playgroud)
一旦我删除android:backgroundtint标记,错误就消失了.知道为什么会这样吗?
尝试在我的应用程序中创建自定义 SurfaceView 视图时出现错误。
<com.example.test.CustomSurfaceView
android:id="@+id/cameraPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)
这是课程:
package com.example.test;
import android.content.Context;
import android.hardware.Camera;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.util.List;
public class CustomSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
private static final String TAG = "CameraPreview";
private Context mContext;
private SurfaceHolder mHolder;
private Camera mCamera;
private List<Camera.Size> mSupportedPreviewSizes;
private Camera.Size mPreviewSize;
public CustomSurfaceView(Context context, Context mContext) {
super(context);
this.mContext = mContext;
}
public CustomSurfaceView(Context context, Camera camera) {
super(context);
mContext = context;
mCamera = camera;
// supported preview sizes …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试将一些数据从我的片段传递到一个活动。我正在传递一些参数,以及一个模型类的数组列表。我已经确保传递之前的数组列表不为空,因为我能够打印出日志中的值。但它在被调用的活动中变为空。
这是模型类:
public class Product implements Parcelable {
String code, id, status, is_expired;
public Product() {}
public Product(String code, String id, String status, String is_expired) {
this.code = code;
this.id = id;
this.status = status;
this.is_expired = is_expired;
}
public Product(Parcel in) {
code = in.readString();
id = in.readString();
status = in.readString();
is_expired = in.readString();
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getId() {
return id;
}
public …Run Code Online (Sandbox Code Playgroud)