以下は list_item レイアウトです。リスト項目行内のビューテキスト要素と仕切り要素の間に大きな垂直スペースがある理由がわかりませんか? このレイアウトの何が問題になっていますか?
リスト項目の私のレイアウト 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:id="@+id/companyName"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/table_text_selector"/>
<TextView
android:id="@+id/exchange"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/table_text_light_selector"
android:layout_below="@id/companyName"/>
<TextView
android:id="@+id/symbol"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/table_text_light_selector"
android:layout_below="@id/companyName"
android:layout_toLeftOf="@id/exchange"/>
<TextView
android:id="@+id/price"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/table_text_selector"
android:layout_alignParentRight="true"/>
<TextView
android:id="@+id/change"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/table_stock_change_text"
android:layout_alignParentRight="true"
android:layout_below="@id/price"/>
<TextView
android:id="@+id/percentChange"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/table_stock_change_text"
android:layout_alignBaseline="@id/change"
android:layout_alignBottom="@id/change"
android:layout_toLeftOf="@id/change"
android:layout_marginRight="5dp"/>
</RelativeLayout>
これはフラグメントです:
public class StockListFragment extends ItemListFragment<CurrentStock> {
@Inject BootstrapServiceProvider serviceProvider;
@Inject LogoutService logoutService;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Injector.inject(this);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setEmptyText(R.string.no_stocks);
}
@Override
protected void configureList(Activity activity, ListView listView) {
super.configureList(activity, listView);
listView.setFastScrollEnabled(true);
listView.setDividerHeight(0);
getListAdapter().addHeader(activity.getLayoutInflater()
.inflate(R.layout.stock_list_item_labels, null));
}
@Override
LogoutService getLogoutService() {
return logoutService;
}
@Override
public Loader<List<CurrentStock>> onCreateLoader(int id, Bundle args) {
final List<CurrentStock> initialItems = items;
return new ThrowableLoader<List<CurrentStock>>(getActivity(), items) {
@Override
public List<CurrentStock> loadData() throws Exception {
try {
List<CurrentStock> latest = null;
if(getActivity() != null)
latest = serviceProvider.getService(getActivity()).getStocks();
if (latest != null)
return latest;
else
return Collections.emptyList();
} catch (OperationCanceledException e) {
Activity activity = getActivity();
if (activity != null)
activity.finish();
return initialItems;
}
}
};
}
public void onListItemClick(ListView l, View v, int position, long id) {
CurrentStock currentStock = ((CurrentStock) l.getItemAtPosition(position));
startActivity(new Intent(getActivity(), StockActivity.class).putExtra(STOCK, currentStock));
}
@Override
public void onLoadFinished(Loader<List<CurrentStock>> loader, List<CurrentStock> items) {
super.onLoadFinished(loader, items);
}
@Override
protected int getErrorMessage(Exception exception) {
return R.string.error_loading_stocks;
}
@Override
protected SingleTypeAdapter<CurrentStock> createAdapter(List<CurrentStock> items) {
return new StockListAdapter(getActivity().getLayoutInflater(), items);
}
}
これがアダプターです
public class StockListAdapter extends SingleTypeAdapter<CurrentStock> {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MMMM dd");
/**
* Create adapter
*
* @param inflater
* @param items
*/
public StockListAdapter(LayoutInflater inflater, List<CurrentStock> items) {
super(inflater, R.layout.stock_list_item);
setItems(items);
}
/**
* Create adapter
*
* @param inflater
*/
public StockListAdapter(LayoutInflater inflater) {
this(inflater, null);
}
@Override
public long getItemId(final int position) {
final String id = getItem(position).getSymbol();
return !TextUtils.isEmpty(id) ? id.hashCode() : super
.getItemId(position);
}
/**/
@Override
protected int[] getChildViewIds() {
return new int[] { R.id.companyName, R.id.exchange, R.id.symbol, R.id.price, R.id.change, R.id.percentChange };
}
@Override
protected void update(int position, CurrentStock currentStock) {
setText(0, currentStock.getCompanyName());
setText(1, currentStock.getExchange());
setText(2, currentStock.getSymbol());
setText(3, currentStock.getPrice().toString());
setText(4, currentStock.getChange().toString());
setText(5, currentStock.getPercentChange());
}
}
私はそれ自身のリストビューを持っていません。ところで。上下の仕切り以外に仕切りが必要ですか?