作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有标题图像的 ListView ,图像的顶部和底部有额外的空间。我想删除其中的空格,
我的布局是 LinierLayout 如果有人知道请帮忙吗?我的 xml 文件已损坏
this is the code for list items xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:textColor="@android:color/white"
android:id="@+id/tvHeader"
android:visibility="gone" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvHeader"
android:orientation="horizontal"
android:paddingLeft="10dp">
<ImageView
android:id="@+id/imageView"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="10dp"
android:layout_marginStart="0dp"
android:layout_marginTop="10dp"
android:paddingBottom="0dp"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="10dp"/>
<!-- img -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="15dp"
android:layout_marginTop="30dp"
android:layout_marginRight="5dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/fname"
android:text="Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="12sp"
android:textStyle="bold"
android:layout_weight="1"/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lname"
android:textColor="#000"
android:textSize="12sp"
android:textStyle="bold"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/organizationname"
android:textSize="10sp"
android:paddingTop="10px" />
<TextView
android:text="yyyyyyyyyyyyyyyyy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/idposition"
android:textSize="10sp"
android:layout_below="@+id/fname"
android:layout_alignLeft="@+id/fname"
android:layout_alignStart="@+id/fname" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
this is adapter file
import android.content.*;
import android.graphics.*;
import android.os.*;
import android.util.Log;
import android.view.*;
import android.widget.*;
import com.parse.*;
import com.squareup.picasso.*;
import org.w3c.dom.Text;
import java.io.*;
import java.net.*;
import java.util.*;
public class IndividualsAdaptor extends ArrayAdapter {
private static final int TYPE_SECTION_HEADER = 0;
private static final int TYPE_LIST_ITEM = 1;
protected Context mContext;
ArrayList<Integer> mListHeader = new ArrayList<>();
// Code for Custom Filter.
protected List mBackupList = new ArrayList();
public IndividualsAdaptor(Context context, List status) {
super(context, R.layout.t3, status);
mContext = context;
// Code for Custom Filter.
mBackupList.addAll(status);
}
@Override
public int getViewTypeCount() { return 2; }
@Override
public int getItemViewType(int position)
{
if (mListHeader.contains(position)){
return TYPE_SECTION_HEADER;
} else {
return TYPE_LIST_ITEM;
}
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.t3, null);
holder = new ViewHolder();
holder.tvHeader = (TextView) convertView.findViewById(R.id.tvHeader);
holder.usernameHomepage = (TextView) convertView.findViewById(R.id.fname);
holder.statusHomepage = (TextView) convertView.findViewById(R.id.lname);
holder.pposition = (TextView) convertView.findViewById(R.id.idposition);
holder.orgName = (TextView) convertView.findViewById(R.id.organizationname);
holder.logo = (ImageView) convertView.findViewById(R.id.imageView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ParseObject statusObject = (ParseObject) getItem(position);
// title
String username = statusObject.getString("firstname");
holder.usernameHomepage.setText(username);
// content
String status = statusObject.getString("lastname");
holder.statusHomepage.setText(status);
// Header
if(getItemViewType(position) == TYPE_SECTION_HEADER){
holder.tvHeader.setVisibility(View.VISIBLE);
holder.tvHeader.setText(String.valueOf(status.charAt(0)));
}else{
holder.tvHeader.setVisibility(View.GONE);
}
// content
String positions = statusObject.getString("position");
holder.pposition.setText(positions);
// content
String org = statusObject.getString("organizationName");
holder.orgName.setText(org);
// logo
URL url = null;
Bitmap bmp = null;
try {
url = new URL("file location" + statusObject.getString("image"));
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (MalformedURLException e) {
}catch (IOException e) {
}
holder.logo.setImageBitmap(bmp);
Picasso.with(mContext)
.load(String.valueOf(url))
.transform(new Rounded( ))
.into(((ImageView) convertView
.findViewById(R.id.imageView)));
return convertView;
}
public static class ViewHolder {
TextView tvHeader;
TextView usernameHomepage;
TextView statusHomepage;
TextView orgName;
TextView pposition;
ImageView logo;
}
@Override
public Filter getFilter() {return new Filter(){
@Override
protected FilterResults performFiltering(CharSequence charSequence) {
String queryString = charSequence.toString().toLowerCase();
List<ParseObject> filteredList = new ArrayList<>();
ParseObject tmpItem;
String tmpUsername, tmpStatus, tmpPositions, tmpOrg;
for(int i=0; i<mBackupList.size(); i++){
tmpItem = (ParseObject) mBackupList.get(i);
tmpUsername = tmpItem.getString("firstname").toLowerCase();
tmpStatus = tmpItem.getString("lastname").toLowerCase();
tmpPositions = tmpItem.getString("position").toLowerCase();
tmpOrg = tmpItem.getString("organizationName").toLowerCase();
// The matching condition
if(tmpUsername.contains(queryString)||tmpStatus.contains(queryString)||
tmpPositions.contains(queryString)||tmpOrg.contains(queryString)){
filteredList.add(tmpItem);
}
}
FilterResults filterResults = new FilterResults();
filterResults.count = filteredList.size();
filterResults.values = filteredList;
return filterResults;
}
@Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
clear();
addAll((List<ParseObject>) filterResults.values);
}
};}
public void updateBackupList(List newList){
mBackupList.clear();
mBackupList.addAll(newList);
}
public void updateHeaderList(ArrayList<HashMap> newHeaderList){
for(int i=0; i<newHeaderList.size(); i++){
mListHeader.add(Integer.parseInt((String)newHeaderList.get(i).get("position")));
}
Log.d("Test", mListHeader.toString());
}
}
java file
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="110dp"
/>
<TextView android:id="@+id/tvEmpty"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#083266"/>
<SearchView
android:id="@+id/ser1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:queryHint="Search.."
android:background="@color/FBC_RED"
android:layout_below="@id/tvEmpty"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="0dp">
</SearchView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_below="@+id/ser1">
<ListView
android:id="@id/android:list"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.89" />
<ListView
android:id="@+id/listIndex"
android:layout_width="0dp"
android:layout_height="match_parent"
android:scrollbars="none"
android:layout_weight="0.08">
</ListView>
</LinearLayout>
</LinearLayout>
最佳答案
这应该有效:
ListView listView = getListView();
ImageView mListHeader = new ImageView(getContext());
mListHeader.setImageResource(R.drawable.individuals_img);
mListHeader.setScaleType(ImageView.ScaleType.FIT_XY);
mListHeader.setLayoutParams(new AbsListView.LayoutParams(1400,974));
mListHeader.requestLayout();
listView.addHeaderView(mListHeader);
关于java - ANDROID - 删除 ListView 标题图像的多余空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42605383/
我的服务层有如下方法 public ModuleResponse GetModules(ModuleRequest request) { var response = new ModuleRe
我构建的工具栏与大多数工具栏一样,minHeight 设置为 actionBarSize: 但是,如果我删除这个属性,就完全没有区别了。工具栏保持其 actionBarSize,即使我删除菜单并将
我已经为 SVG 和剪辑路径苦苦挣扎了一段时间。 我正在尝试创建一个三 Angular 形剪辑路径,它将覆盖照片以给顶部一个“三 Angular 形”边缘。 我试图实现与照片完全相同的效果,但三 An
我有一个带有 2 个索引的 PostgreSQL 表。其中一个索引涵盖了 website_id 和 tweet_id 列,是一个唯一的 B 树索引。第二个索引只覆盖 website_id 列,是一个非
我是一名优秀的程序员,十分优秀!