2

Имеется таблица с элементами. Столбцы которой отдалены друг от друга. Как сделать так, чтобы можно было убрать отступы между столбцами?

Вот, где я создаю программно GridView:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        GridView gridView = (GridView)findViewById(R.id.linear);
        context=this;
        createList(28);
        buttonAdapter=new ButtonAdapter(this,R.layout.item,list);
        gridView.setNumColumns(4);
        gridView.setAdapter(buttonAdapter);

        GridView.OnItemClickListener itemClickListener=new AdapterView.OnItemClickListener(){

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                list.get(position).setBackgroundResource(R.drawable.but);
                Log.e("Dfsdf",list.get(position).getText().toString());
                buttonAdapter.notifyDataSetChanged();
            }

        };
        gridView.setOnItemClickListener(itemClickListener);

    }

Вот главная разметка XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="neural_networks.bstu.com.myapplication.MainActivity">



        <GridView
            android:id="@+id/linear"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            tools:layout_editor_absoluteX="8dp"
            tools:layout_editor_absoluteY="8dp"></GridView>

</android.support.constraint.ConstraintLayout>

А вот разметка содержимого GridView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textView"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_marginLeft="0dp"
        android:layout_gravity="center"
        android:layout_marginRight="0dp"


        />
</LinearLayout>

1 ответ 1

1
android:verticalSpacing="0px" 
android:horizontalSpacing="0px"
7
  • пробывал не получилось 22 сен 2017 в 13:36
  • Добавил разметку, посмотрите, пожалуйста 22 сен 2017 в 13:39
  • напишите мне на почту martsinke[email protected] данные для подключения через теамвивер и посмотрю 22 сен 2017 в 16:26
  • Проблема была в фиксированной картинке 24 сен 2017 в 10:52
  • в будущем можно использовать следующий лайфхак - в меню для разработчиков есть пункт "отображать границы" и если его включить то сразу станет видно что именно занимает место. 24 сен 2017 в 14:05

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.