我希望有人可以帮助我,我有一个网格布局,由8个项目的适配器填充.网格中有三列,这留下了两行,其中三列为完整列,另一行为两列,末尾为空白.我附上图片来详细说明我想要实现的目标.我希望能够拉伸最后一行行列以填充gridview的宽度.这是由适配器填充.
下面是应用程序的现状,我有8个单元格的内容,没有第九个单元格,以防与我的图像混淆.

这是我希望它的样子.
所以我想将两个单元拉伸到三列.
以下是我到目前为止实施的代码
public class channels_fragment extends Fragment {
private View view;
private GridView channelsGridView;
protected Handler handler;
//protected GridAdapter gridAdapter;
private Main_Activity main;
private final ChannelsModel model = new ChannelsModel();
static final String[] channelTitles = new String[]{"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8"};
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
main = (Main_Activity) this.getActivity();
view = inflater.inflate(R.layout.channels_fragment_layout, null);
channelsGridView = (GridView)view.findViewById(R.id.channelsGrid);
channelsGridView.setAdapter(new ImageAdapter(this.getActivity(), channelTitles));
channelsGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, …Run Code Online (Sandbox Code Playgroud) 我已经为我的网格视图实现了一个刷卡刷新布局,如果我向下拉(滚动)以调用刷新,它就可以正常工作.
但是,我试图弄清楚当用户向上滚动时如何刷新.因此,当用户到达网格中的最后一个项目时(我的限制为10),所以当用户看到全部十个然后向上拉或尝试继续滚动时,我该如何刷新?
任何帮助表示赞赏.
我有一个具有登录屏幕的应用程序,有两个选项,1个用twitter登录,2个用户名和密码.
这个应用程序在商店现场直播,但是,我目前正在收到一些拒绝api.parse.com连接的报告.我已经在多个设备上进行了测试,并且连接正常.
除了服务器出现问题之外,是否还有任何原因可能会拒绝解析连接?设备imei等可以发挥作用吗?我发现这种情况很不寻常,一些人而不是其他人正在发生这种情况.另外,我最终会以这种方式失去很多用户.
任何指导表示赞赏.
如果有人对此有任何了解,我真的很感激任何帮助,parse.com状态说它完全可以操作,不再有解析论坛了,如果有人能给我一些见解它会很棒
我正在尝试创建动态RecyclerView布局。我使用的是GridLayoutManager三列。
我需要包装每个网格项并将列居中(如附件所示)。
我试过一个StaggeredGridLayout,我试过一个WrapGridLayoutManager 但这些都不起作用。
这是我的RecyclerView:
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/categories_grid"
android:layout_marginTop="@dimen/feed_item_margin"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
Run Code Online (Sandbox Code Playgroud)
和我的RecyclerView项目:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:background="@drawable/first_time_category_unselected"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="@+id/category_name"
android:layout_marginLeft="@dimen/feed_item_margin"
android:layout_gravity="center_vertical"
android:textColor="@color/black_colour"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/category_status_icon"
android:layout_gravity="center_vertical"
android:background="@drawable/icon_follow"
android:layout_marginLeft="@dimen/feed_item_margin"
android:layout_marginRight="@dimen/feed_item_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我用来实现网格间距的装饰:
public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
private int halfSpace;
public SpacesItemDecoration(int space) {
this.halfSpace = space / 2;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State …Run Code Online (Sandbox Code Playgroud) 我正在开发一个用户可以将内容发布到Feed的应用程序.在我的编辑文本(用于撰写)中,文本颜色为灰色.但是,当用户键入一个哈希标记,例如#help时,我需要在键入时将该文本着色为黑色,因此当用户键入"#"时,文本必须为黑色,直到它们开始一个新单词,然后文本颜色需要还原灰色
我一直在尝试使用文本观察器和spannable字符串进行着色.
这是我用textwatcher做的 onTextChanged
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//Remove Text watcher to prevent infinite look
mTextField.removeTextChangedListener(contentFieldWatcher);
String startChar = null;
startChar = Character.toString(s.charAt(start));
L.i(getClass().getSimpleName(), "CHARACTER OF NEW WORD: " + startChar);
if (startChar.equals("#")) {
tagCheck(s.toString().substring(start), start, start + count);
}
}
Run Code Online (Sandbox Code Playgroud)
tagCheck方法
private void tagCheck(String s, int start, int end) {
mSpannable.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.black_colour)), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
Run Code Online (Sandbox Code Playgroud)
mSpannable是一个Spannable.
这种方法的问题是'#'显示为startChar,但是当用户键入下一个字符(符号或字母)时,它显示为startChar.用户键入圣诞老人的情况仍然是startChar.所以我面临的问题是如何在用户键入主题标签时动态着色文本.
所以普通字母可以正常工作,但是当你使用符号时它不会.我希望这个问题很清楚..我已经看了几天这一切都变得朦胧:)
我的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/logo_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/logos_background">
</ImageView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:layout_alignBottom="@+id/logo_background"
>
<TextView
android:id="@+id/logoDetails"
android:text="Test Logo details"
android:textSize="15sp"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/stockQuantity"
android:layout_centerHorizontal="true"
android:textSize="20sp"
android:layout_below="@+id/logoDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="x10"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我需要在另一个布局中多次包含此布局,我已完成如下操作:
<HorizontalScrollView
android:layout_below = "@+id/selectLayout"
android:id="@+id/pager"
android:scrollbars="none"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
</LinearLayout> …Run Code Online (Sandbox Code Playgroud) android include horizontal-scrolling android-layout android-viewpager
我有一个与GridLayoutManager一起使用的回收器视图.当用户单击视图项时,视图将使用缩放动画进行动画处理,以显示适配器项的更多详细信息.我有一个按钮来反转这个动画并删除屏幕上的细节.
问题是当显示详细信息视图时,用户仍然可以单击回收器视图并为其他视图设置动画.可以告诉我如何禁用回收者视图?
我试过了 rc_view.setEnabled(false);
rc_view.setClickable(false);
我已经遵循了这一点,他们都没有禁用回收者视图.
有人可以帮忙吗?
我正在开发一个需要直接打印到ESC/POS打印机的应用程序.打印很好,但是当向打印机发出命令时,它们只是打印!! 我正在尝试转换一些c#代码,我尝试发送的命令是十六进制字符串,如下所示:
public static String PRINTLOGOCOMPANY = "\x1c\x70\x01\x30";
Run Code Online (Sandbox Code Playgroud)
当然我知道这里有非法的转义字符所以我把它改成了:
"\\x1c\\x70\\x01\\x30"
Run Code Online (Sandbox Code Playgroud)
然后我转换为一个字节数组并尝试通过dataoutput流发送它,如下所示:
String WIDTH_1 ="\\x1d\\x57\\x120\\x01";
Log.i("Width String: ", WIDTH_1);
final byte [] width = WIDTH_1.getBytes();
final int portNo = xxxx;
final String ipAddress = "xxx.xxx.x.xxx";
Thread thread = new Thread() {
@Override
public void run() {
try {
Socket sock = new Socket(ipAddress, portNo);
DataOutputStream dOut = new DataOutputStream(sock.getOutputStream());
dOut.writeInt(width.length);
dOut.write(width);
dOut.close();
sock.close();
} catch (UnknownHostException e) {
e.printStackTrace();
Log.i("Unknown Host Exception Error: ", String.valueOf(e));
} catch (IOException e) {
e.printStackTrace(); …Run Code Online (Sandbox Code Playgroud) 我正在创建数据对象的循环器视图,这些对象中的每一个都会有所不同,例如.
对象1 - 字符串标题 - 字符串描述 - 图像
Obj 2 - 字符串描述
对象3 - 图像 - 字符串链接
对象4 - 字符串描述 - 视频
等等
所以我需要动态创建项目布局以适应每个数据对象.我不想创建包含所有可能的视图和组件的项目布局,并显示和隐藏,因为我认为这是不好的做法.
所以我的问题是我需要使用onBindViewHolder中的位置从列表中访问一个对象,以便在ViewHolder类中构建我的布局.
我尝试使用我在onBindViewHolder类中调用的方法并传入我在其中向数组添加自定义视图的对象,同时在内部设置内容但这不起作用.
有谁知道如何做到这一点?
问候
android android-layout recycler-adapter android-recyclerview
我正在使用Fresco库将图像和GIF加载到我的应用程序中.我在Fresco遇到的一个重要限制是必须设置布局宽度和高度.所以我设置了这样简单的drawee视图:
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/image"
android:layout_marginTop="@dimen/feed_item_margin"
android:scaleType="fitCenter"
fresco:actualImageScaleType="fitStart"
android:layout_below="@+id/content_header"
android:layout_width="match_parent"
android:layout_height="@dimen/texture_view_height"
fresco:placeholderImage="@drawable/placeholder"
/>
Run Code Online (Sandbox Code Playgroud)
我的问题是如果图像高度大于宽度,图像右侧会留下很多空白区域(见附件),但是高度很好
然后它可能发生在高度,如果实际图像小于宽度(见附件)所以这里因为固定高度是250dp在图像下面有很多白色空间.
我已经浏览了SimpleDrawerView中的不同scaleTypes,似乎没有一个能够显示我想要的方式.
我想知道有没有人有过Fresco的经验?我已经开始使用它来加载GIF了,因为我遇到了Glide问题.
如果有人可以提供帮助,我会非常感激.
仅供参考这些图像是从服务器流式传输的,我无法控制图像